Skip to content

Commit

Permalink
more Branchy refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
kikito committed Apr 11, 2011
1 parent d297d5f commit edba567
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Branchy.lua
Expand Up @@ -51,6 +51,16 @@ local function _applySorted(collection, sortFunc, methodOrName, ...)
end
end

local function _modifyAllocateMethod(theClass)
local oldAllocate = theClass.allocate

function theClass.allocate(theClass)
local instance = oldAllocate(theClass)
instance.children = {}
return instance
end
end


--------------------------------
-- PUBLIC STUFF
Expand Down Expand Up @@ -187,9 +197,8 @@ end
function Branchy:included(theClass)
theClass:include(Callbacks)

theClass:before('initialize', function(self)
self.children = {}
end)
_modifyAllocateMethod(theClass)

theClass:after('destroy', 'removeAllChildren')
end

Expand Down

0 comments on commit edba567

Please sign in to comment.