diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-09-15 13:15:48 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-09-15 13:15:48 +0100 |
commit | 4e3cace514317d2535a7b811ecb9b4d962502d48 (patch) | |
tree | 0115160f7877bfbd76b58db6aabe29789d241ee8 /lualib/lua_selectors.lua | |
parent | fed99b23a32982fd55195c926a12250d530320c7 (diff) | |
download | rspamd-4e3cace514317d2535a7b811ecb9b4d962502d48.tar.gz rspamd-4e3cace514317d2535a7b811ecb9b4d962502d48.zip |
[Minor] Add method create_selector_closure
Diffstat (limited to 'lualib/lua_selectors.lua')
-rw-r--r-- | lualib/lua_selectors.lua | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua index cef2d163f..06e23fc80 100644 --- a/lualib/lua_selectors.lua +++ b/lualib/lua_selectors.lua @@ -702,6 +702,27 @@ exports.combine_selectors = function(_, selectors, delimiter) end end +--[[[ +-- @function lua_selectors.create_closure(cfg, selector_str, delimiter='') +--]] +exports.create_selector_closure = function(cfg, selector_str, delimiter) + local selector = exports.parse_selector(cfg, selector_str) + + if not selector then + return nil + end + + return function(task) + local res = exports.process_selectors(task, selector) + + if res then + return exports.combine_selectors(_, res, delimiter) + end + + return nil + end +end + local function display_selectors(tbl) return fun.tomap(fun.map(function(k,v) return k, fun.tomap(fun.filter(function(kk, vv) |