Skip to content

Commit

Permalink
[Minor] Also allow to pass callback in the get_key method
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Nov 19, 2022
1 parent ba3fd03 commit 78a67ee
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lualib/lua_maps.lua
Expand Up @@ -99,12 +99,14 @@ end
local function rspamd_map_add_from_ucl(opt, mtype, description, callback)
local ret = {
get_key = function(t, k)
get_key = function(t, k, key_callback)
if t.__data then
local result = t.__data:get_key(k)
if callback then
callback(result)
elseif key_callback then
key_callback(result)
else
return result
end
Expand All @@ -114,9 +116,9 @@ local function rspamd_map_add_from_ucl(opt, mtype, description, callback)
end
}
local ret_mt = {
__index = function(t, k)
__index = function(t, k, key_callback)
if t.__data then
return t.get_key(k)
return t.get_key(k, key_callback)
end
return nil
Expand Down

0 comments on commit 78a67ee

Please sign in to comment.