From bdcf6ff099f1acd7e2370a2478b5b4a5eac7dea0 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Wed, 19 Mar 2014 13:38:32 +0200 Subject: model: allow deletion of models from non-editable collections requires defining the is_removable method for the model --- aconf/model/node.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'aconf/model') diff --git a/aconf/model/node.lua b/aconf/model/node.lua index 9a4f477..741aaeb 100644 --- a/aconf/model/node.lua +++ b/aconf/model/node.lua @@ -111,15 +111,16 @@ function M.TreeNode:init(context, params) return getmetatable(next).fetch(path, create) end - function mt.removable() return true end + function mt.removable() end function mt.value_removable(v) - return not isinstance(v, M.TreeNode) or getmetatable(v).removable() + if isinstance(v, M.TreeNode) then return getmetatable(v).removable() end end local function key_removable(k) - return params.editable and - mt.value_removable(mt.load(k, {dereference=false})) + local res = mt.value_removable(mt.load(k, {dereference=false})) + if res == nil then return params.editable end + return res end function mt.check_removable(k, v) -- cgit v1.2.3