diff options
author | Steven Barth <steven@midlink.org> | 2008-07-28 13:07:22 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-07-28 13:07:22 +0000 |
commit | 84ad4e3e21b53c84cb6d1dc6f6dbae97e24f9d94 (patch) | |
tree | 518c3dac754b0e62e40927897ce1533bb0765bb1 /libs/core | |
parent | 3b29503f1302ae66a5c2b590eda86334a550b57b (diff) |
libs/core: Add luci.util.create_dtable
Diffstat (limited to 'libs/core')
-rw-r--r-- | libs/core/luasrc/util.lua | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libs/core/luasrc/util.lua b/libs/core/luasrc/util.lua index 48b6fa063..22f295d23 100644 --- a/libs/core/luasrc/util.lua +++ b/libs/core/luasrc/util.lua @@ -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 = "" |