mirror of
https://github.com/vrld/hump.git
synced 2024-11-23 12:24:19 +00:00
Remove name inference in class.lua.
This commit is contained in:
parent
f5adba2cb8
commit
9d76e4d020
16
class.lua
16
class.lua
@ -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))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user