From: Steven Barth Date: Thu, 4 Sep 2008 11:48:27 +0000 (+0000) Subject: Add table-comparators to luci.model.uci.delete_all X-Git-Tag: 0.8.0~160 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e4cbd59c393f337cc4e4ad1cf2b00431e6a1caca;p=oweals%2Fluci.git Add table-comparators to luci.model.uci.delete_all --- diff --git a/libs/uci/luasrc/model/uci.lua b/libs/uci/luasrc/model/uci.lua index 82c76ced2..8da73fe61 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