From 5c78058e6eb6e303e27056d6cb338a22fadbab18 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 13 Sep 2018 15:16:08 +0100 Subject: [Minor] Add generic list type for processors in selectors --- lualib/lua_selectors.lua | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua index 112443fd3..66f2906d1 100644 --- a/lualib/lua_selectors.lua +++ b/lualib/lua_selectors.lua @@ -302,10 +302,7 @@ local transform_function = { -- Returns the first element ['first'] = { ['types'] = { - ['url_list'] = true, - ['kv_list'] = true, - ['received_list'] = true, - ['string_list'] = true + ['list'] = true, }, ['process'] = function(inp, t) return inp[1],pure_type(t) @@ -315,9 +312,7 @@ local transform_function = { -- Returns the last element ['last'] = { ['types'] = { - ['url_list'] = true, - ['kv_list'] = true, - ['string_list'] = true + ['list'] = true, }, ['process'] = function(inp, t) return inp[#inp],pure_type(t) @@ -327,9 +322,7 @@ local transform_function = { -- Returns the nth element ['nth'] = { ['types'] = { - ['url_list'] = true, - ['kv_list'] = true, - ['string_list'] = true + ['list'] = true, }, ['process'] = function(inp, t, args) return inp[tonumber(args[1] or 1)],pure_type(t) @@ -470,7 +463,10 @@ local function process_selector(task, sel) if not x.types[t] then -- Additional case for map local pt = pure_type(t, '^(.*)_list$') - if pt and x.map_type and x.types[pt] then + if x.types['list'] then + -- Generic list + return {x.process(value, t, x.args)} + elseif pt and x.map_type and x.types[pt] then return {fun.map(function(list_elt) local ret, _ = x.process(list_elt, pt, x.args) return ret -- cgit v1.2.3