projects
/
project
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
fb1c51b
)
Add table-comparators to luci.model.uci.delete_all
author
Steven Barth
<steven@midlink.org>
Thu, 4 Sep 2008 11:48:27 +0000
(11:48 +0000)
committer
Steven Barth
<steven@midlink.org>
Thu, 4 Sep 2008 11:48:27 +0000
(11:48 +0000)
libs/uci/luasrc/model/uci.lua
patch
|
blob
|
history
diff --git
a/libs/uci/luasrc/model/uci.lua
b/libs/uci/luasrc/model/uci.lua
index
82c76ce
..
8da73fe
100644
(file)
--- a/
libs/uci/luasrc/model/uci.lua
+++ b/
libs/uci/luasrc/model/uci.lua
@@
-69,7
+69,21
@@
end
-- returns a boolean whether to delete the current section (optional)
function Cursor.delete_all(self, config, type, comparator)
local del = {}
-- returns a boolean whether to delete the current section (optional)
function Cursor.delete_all(self, config, type, comparator)
local del = {}
+
+ if type(comparator) == "table" then
+ local tbl = comparator
+ comparator = function(section)
+ for k, v in pairs(tbl) do
+ if not section[k] == v then
+ return false
+ end
+ end
+ return true
+ end
+ end
+
local function helper (section)
local function helper (section)
+
if not comparator or comparator(section) then
table.insert(del, section[".name"])
end
if not comparator or comparator(section) then
table.insert(del, section[".name"])
end