diff options
author | Steven Barth <steven@midlink.org> | 2008-09-04 11:48:27 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-09-04 11:48:27 +0000 |
commit | e4cbd59c393f337cc4e4ad1cf2b00431e6a1caca (patch) | |
tree | 7f1979108adb735560e8a394805f4e6c88e84d21 /libs | |
parent | fb1c51b33c6dd517802393acfe7219e38de2a800 (diff) |
Add table-comparators to luci.model.uci.delete_all
Diffstat (limited to 'libs')
-rw-r--r-- | libs/uci/luasrc/model/uci.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libs/uci/luasrc/model/uci.lua b/libs/uci/luasrc/model/uci.lua index 82c76ced2a..8da73fe618 100644 --- 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 = {} + + 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) + if not comparator or comparator(section) then table.insert(del, section[".name"]) end |