libs/core: Add luci.util.create_dtable
This commit is contained in:
parent
3b29503f13
commit
84ad4e3e21
1 changed files with 13 additions and 0 deletions
|
@ -375,6 +375,19 @@ function clone(object, deep)
|
|||
return copy
|
||||
end
|
||||
|
||||
|
||||
--- Create a dynamic table which automatically creates subtables.
|
||||
-- @return Dynamic Table
|
||||
function create_dtable()
|
||||
return setmetatable({}, { __index =
|
||||
function(tbl, key)
|
||||
return rawget(tbl, key)
|
||||
or rawget(rawset(tbl, key, create_dtable()), key)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
-- Serialize the contents of a table value.
|
||||
function _serialize_table(t)
|
||||
local data = ""
|
||||
|
|
Loading…
Reference in a new issue