mirror of
https://github.com/leafo/moonscript.git
synced 2024-12-08 01:54:24 +00:00
fix moon.mixin, fixes #99
This commit is contained in:
parent
2f4066d9bb
commit
fcf36aeb8c
@ -117,8 +117,7 @@ copy = function(self)
|
|||||||
end)()
|
end)()
|
||||||
end
|
end
|
||||||
mixin = function(self, cls, ...)
|
mixin = function(self, cls, ...)
|
||||||
local meta = getmetatable(cls)
|
for key, val in pairs(cls.__base) do
|
||||||
for key, val in pairs(meta.__index) do
|
|
||||||
if not key:match("^__") then
|
if not key:match("^__") then
|
||||||
self[key] = val
|
self[key] = val
|
||||||
end
|
end
|
||||||
|
@ -100,8 +100,7 @@ copy = =>
|
|||||||
|
|
||||||
-- mixin class properties into self, call new
|
-- mixin class properties into self, call new
|
||||||
mixin = (cls, ...) =>
|
mixin = (cls, ...) =>
|
||||||
meta = getmetatable cls
|
for key, val in pairs cls.__base
|
||||||
for key, val in pairs meta.__index
|
|
||||||
self[key] = val if not key\match"^__"
|
self[key] = val if not key\match"^__"
|
||||||
cls.__init self, ...
|
cls.__init self, ...
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user