class LightRulesEngine::OperatorContxt

Attributes

data_provider[R]
operator_hash[R]

Public Class Methods

new(operator_hash, data_provider) click to toggle source
# File lib/light_rules_engine/operator_contxt.rb, line 3
def initialize(operator_hash, data_provider)
  @operator_hash = operator_hash
  @data_provider = data_provider
end

Public Instance Methods

operator() click to toggle source
# File lib/light_rules_engine/operator_contxt.rb, line 8
def operator
  @operator ||= config[:operators_namespace].find(operator_hash[:type])
end
result() click to toggle source
# File lib/light_rules_engine/operator_contxt.rb, line 16
def result
  operator.result(*values)
end
values() click to toggle source
# File lib/light_rules_engine/operator_contxt.rb, line 12
def values
  operator_hash[:values].map(&method(:resolve))
end

Private Instance Methods

config() click to toggle source
# File lib/light_rules_engine/operator_contxt.rb, line 28
def config
  @config ||= LightRulesEngine.config
end
resolve(value) click to toggle source
# File lib/light_rules_engine/operator_contxt.rb, line 24
def resolve(value)
  config[:value_resolver_class].new(data_provider: data_provider).resolve(value)
end