Class: Qreds::CatchAllFunctor

Inherits:
Functor
  • Object
show all
Defined in:
lib/qreds/catch_all_functor.rb

Instance Method Summary collapse

Constructor Details

#initialize(query, value, context, key, config) ⇒ CatchAllFunctor

Returns a new instance of CatchAllFunctor.

Parameters:

  • query (any)

    the query to adjust

  • value (any)

    the parameter value

  • context (any)
  • key (String)

    the parameter name

  • config (Qreds::Config)

    current reducer config



8
9
10
11
12
13
# 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

Instance Method Details

#callObject



15
16
17
18
19
20
21
# 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