class Qreds::CatchAllFunctor
Attributes
config[R]
key[R]
Public Class Methods
new(query, value, context, key, config)
click to toggle source
@param query [any] the query to adjust @param value [any] the parameter value @param context [any] @param key [String] the parameter name @param config [Qreds::Config] current reducer config
Calls superclass method
# File lib/qreds/catch_all_functor.rb, line 8 def initialize(query, value, context, key, config) super(query, value, context) @key = key @config = config end
Public Instance Methods
call()
click to toggle source
# File lib/qreds/catch_all_functor.rb, line 15 def call head, _, tail = key.rpartition('_') operator = map_operator(tail) attr_name = operator.nil? ? key : head config.default_lambda.call(query, attr_name, value, operator, context) end
Private Instance Methods
map_operator(operator)
click to toggle source
# File lib/qreds/catch_all_functor.rb, line 27 def map_operator(operator) return nil if config.operator_mapping.nil? mapped = config.operator_mapping[operator] raise "No operator mapping found for #{operator}" if mapped.nil? mapped end