summaryrefslogtreecommitdiffstats
path: root/aconf/model/node.lua
diff options
context:
space:
mode:
Diffstat (limited to 'aconf/model/node.lua')
-rw-r--r--aconf/model/node.lua15
1 files changed, 8 insertions, 7 deletions
diff --git a/aconf/model/node.lua b/aconf/model/node.lua
index 43f06e9..6cca48e 100644
--- a/aconf/model/node.lua
+++ b/aconf/model/node.lua
@@ -16,6 +16,7 @@ local pth = require('aconf.path')
local util = require('aconf.util')
local copy = util.copy
+local setdefaults = util.setdefaults
local update = util.update
@@ -58,7 +59,7 @@ local function equal_tns(tn1, tn2)
return getmetatable(tn1).path == getmetatable(tn2).path
end
-function M.TreeNode:init(context, dtype, editable)
+function M.TreeNode:init(context, params)
local mt = getmetatable(self)
update(mt, context)
@@ -67,7 +68,7 @@ function M.TreeNode:init(context, dtype, editable)
function mt.meta()
if not mt._meta then
- mt._meta = {type=dtype}
+ mt._meta = {type=params.dtype}
if mt.txn then
if mt.parent then
mt._meta['ui-name'] =
@@ -84,7 +85,7 @@ function M.TreeNode:init(context, dtype, editable)
function mt.member_removable(k)
local v = mt.load(k, {dereference=false})
- return editable and (
+ return params.editable and (
not isinstance(v, M.TreeNode) or getmetatable(v).removable()
)
end
@@ -195,9 +196,9 @@ end
M.Collection = class(M.TreeNode)
-function M.Collection:init(context, params, dtype)
+function M.Collection:init(context, params)
super(self, M.Collection):init(
- context, dtype or 'collection', params.editable
+ context, setdefaults(params, {dtype='collection'})
)
self.init = nil
@@ -286,8 +287,8 @@ end
M.List = class(M.Collection)
-function M.List:init(context, params, dtype)
- super(self, M.List):init(context, params, dtype or 'list')
+function M.List:init(context, params)
+ super(self, M.List):init(context, setdefaults(params, {dtype='list'}))
local mt = getmetatable(self)