class Qreds::Config

Constants

OPERATOR_MAPPING_COMP_PGSQL

Attributes

default_lambda[RW]
functor_group[RW]
operator_mapping[RW]

Public Class Methods

define_reducer(helper_name, strategy: method(:define_endpoint_method)) { |config| ... } click to toggle source

@param helper_name [Symbol|String] the name of the helper method to be defined @yield config [Hash]

# File lib/qreds/config.rb, line 21
def define_reducer(helper_name, strategy: method(:define_endpoint_method))
  config = new(functor_group: helper_name)

  yield config

  strategy.call(helper_name, config)
end
new(args) click to toggle source

@param args [Hash<#to_s, any>]

# File lib/qreds/config.rb, line 10
def initialize(args)
  args.each do |(key, value)|
    send("#{key}=", value)
  end
end

Private Class Methods

define_endpoint_method(helper_name, config) click to toggle source
# File lib/qreds/config.rb, line 31
def define_endpoint_method(helper_name, config)
  ::Qreds::Endpoint.send(:define_method, helper_name) do |query, context={}, **args|
    functor_group = config.functor_group

    declared_params = declared(params, include_missing: false)[functor_group]

    ::Qreds::Reducer.new(
      query: query,
      params: declared_params,
      config: config,
      context: context,
      **args
    ).call
  end

  @reducers[helper_name] = config
end