mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-12-03 14:24:47 +00:00
feat(class): add temporary super method during class init
This commit is contained in:
1 parent
92dc3688f8
commit
105d265792
1 file changed
+13
-1
@@ -34,7 +34,19 @@ function mixins.new(class, obj)
|
||||
|
||||
setmetatable(obj, class)
|
||||
|
||||
if class.init then obj:init() end
|
||||
if class.init then
|
||||
local parent = class
|
||||
|
||||
function obj:super(...)
|
||||
parent = getmetatable(parent)
|
||||
local superInit = parent and parent.init
|
||||
|
||||
if superInit then return superInit(self, ...) end
|
||||
end
|
||||
|
||||
obj:init()
|
||||
obj.super = nil
|
||||
end
|
||||
|
||||
return obj
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user