mirror of
https://github.com/Keyslam-Group/Concord.git
synced 2025-08-30 00:48:30 -04:00
Changed lib layout once more
This commit is contained in:
parent
6caf99afb4
commit
b1e30e83b1
11 changed files with 2 additions and 2 deletions
36
lib/component.lua
Normal file
36
lib/component.lua
Normal file
|
@ -0,0 +1,36 @@
|
|||
local Component = {}
|
||||
Component.__index = Component
|
||||
|
||||
--- Creates a new Component.
|
||||
-- @param populate A function that populates the Bag with values
|
||||
-- @return A Component object
|
||||
function Component.new(populate)
|
||||
local component = setmetatable({
|
||||
__populate = populate,
|
||||
__inherit = inherit,
|
||||
|
||||
__isComponent = true,
|
||||
}, Component)
|
||||
|
||||
component.__mt = {__index = component}
|
||||
|
||||
return component
|
||||
end
|
||||
|
||||
--- Creates and initializes a new Bag.
|
||||
-- @param ... The values passed to the populate function
|
||||
-- @return A new initialized Bag
|
||||
function Component:__initialize(...)
|
||||
if self.__populate then
|
||||
local bag = setmetatable({}, self.__mt)
|
||||
self.__populate(bag, ...)
|
||||
|
||||
return bag
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
return setmetatable(Component, {
|
||||
__call = function(_, ...) return Component.new(...) end,
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue