mirror of
https://github.com/Keyslam-Group/Concord.git
synced 2025-09-03 21:03:54 -04:00
Utils.shallowCopy as a default serializer/deserializer for Components
This commit is contained in:
parent
9ae805aa43
commit
079c1d0e18
2 changed files with 5 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
||||||
local PATH = (...):gsub('%.[^%.]+$', '')
|
local PATH = (...):gsub('%.[^%.]+$', '')
|
||||||
|
|
||||||
local Components = require(PATH..".components")
|
local Components = require(PATH..".components")
|
||||||
|
local Utils = require(PATH..".utils")
|
||||||
|
|
||||||
local Component = {}
|
local Component = {}
|
||||||
Component.__mt = {
|
Component.__mt = {
|
||||||
|
@ -47,9 +48,11 @@ function Component:__populate() -- luacheck: ignore
|
||||||
end
|
end
|
||||||
|
|
||||||
function Component:serialize() -- luacheck: ignore
|
function Component:serialize() -- luacheck: ignore
|
||||||
|
return Utils.shallowCopy(self, {})
|
||||||
end
|
end
|
||||||
|
|
||||||
function Component:deserialize(data) -- luacheck: ignore
|
function Component:deserialize(data) -- luacheck: ignore
|
||||||
|
Utils.shallowCopy(data, self)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Internal: Creates a new Component.
|
-- Internal: Creates a new Component.
|
||||||
|
|
|
@ -10,6 +10,8 @@ function Utils.shallowCopy(orig, target)
|
||||||
for key, value in pairs(orig) do
|
for key, value in pairs(orig) do
|
||||||
target[key] = value
|
target[key] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return target
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Requires files and puts them in a table.
|
--- Requires files and puts them in a table.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue