Skip to content

Commit

Permalink
Remove name inference in class.lua.
Browse files Browse the repository at this point in the history
  • Loading branch information
vrld committed Mar 31, 2012
1 parent f5adba2 commit 9d76e4d
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions class.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,6 @@ local function new(args)
class.__is_a = {[class] = true}
class.is_a = function(self, other) return not not self.__is_a[other] end

-- intercept assignment in global environment to infer the class name
if not (type(args) == "table" and args.name) then
local env, env_meta, interceptor = getfenv(0), getmetatable(getfenv(0)), {}
function interceptor:__newindex(key, value)
if value == class then
local name = tostring(key)
getmetatable(class).__tostring = function() return name end
end
-- restore old metatable and insert value
setmetatable(env, env_meta)
if env.global then env.global(key) end -- handle 'strict' module
env[key] = value
end
setmetatable(env, interceptor)
end

-- inherit superclasses (see above)
inherit(class, unpack(super))

Expand Down

0 comments on commit 9d76e4d

Please sign in to comment.