Merge pull request #3 from danreeves/fix-delayed-class-hooks
Fix delayed class hooks
This commit is contained in:
commit
2925e4a9f7
1 changed files with 14 additions and 8 deletions
|
@ -499,11 +499,17 @@ end
|
||||||
-- ####################################################################################################################
|
-- ####################################################################################################################
|
||||||
|
|
||||||
-- If class() is called on an object we've delayed for, re-run delayed hooks
|
-- If class() is called on an object we've delayed for, re-run delayed hooks
|
||||||
dmf:hook_safe(_G, "class", function(class_name)
|
dmf:hook(_G, "class", function(func, class_name, ...)
|
||||||
|
local class_object = func(class_name, ...)
|
||||||
if _delayed_obj_names[class_name] then
|
if _delayed_obj_names[class_name] then
|
||||||
dmf:info("%s is now available for previously-delayed hooks.", class_name)
|
dmf:info("%s is now available for previously-delayed hooks.", class_name)
|
||||||
dmf.apply_delayed_hooks()
|
|
||||||
|
|
||||||
_delayed_obj_names[class_name] = nil
|
-- Methods aren't defined yet, so we need to wait for the instance creation to apply delayed hooks
|
||||||
|
dmf:hook_safe(class_object, "new", function ()
|
||||||
|
dmf.apply_delayed_hooks()
|
||||||
|
_delayed_obj_names[class_name] = nil
|
||||||
|
dmf:hook_disable(class_object, "new")
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
return class_object
|
||||||
end)
|
end)
|
Loading…
Add table
Reference in a new issue