From b3bca2a238ff3ce1ad9ef5cbf239ff1dc66b6c92 Mon Sep 17 00:00:00 2001 From: Timothy Date: Sun, 21 Jan 2018 20:57:34 -0600 Subject: [PATCH] adds string arg for isInstanceOf and isSubclassOf --- middleclass.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/middleclass.lua b/middleclass.lua index b118f17..0fd2e20 100644 --- a/middleclass.lua +++ b/middleclass.lua @@ -119,7 +119,9 @@ local DefaultMixin = { initialize = function(self, ...) end, isInstanceOf = function(self, aClass) - return type(aClass) == 'table' and (aClass == self.class or self.class:isSubclassOf(aClass)) + return (type(aClass) == 'table' and (aClass == self.class)) or + (type(aClass) == 'string' and (aClass == self.class)) or + (self.class:isSubclassOf(aClass)) end, static = { @@ -155,9 +157,9 @@ local DefaultMixin = { subclassed = function(self, other) end, isSubclassOf = function(self, other) - return type(other) == 'table' and - type(self.super) == 'table' and - ( self.super == other or self.super:isSubclassOf(other) ) + return (type(other) == 'table' and type(self.super) == 'table' and ( self.super == other)) or + (type(other) == 'string' and type(self.super) == 'table' and (self.super.name == other)) or + (self.super:isSubclassOf(other) ) end, include = function(self, ...)