class RulesProcessor::ConditionMatcher

Attributes

condition[RW]
records[RW]

Public Class Methods

new(args = {}) click to toggle source
# File lib/rules_processor/condition_matcher.rb, line 6
def initialize(args = {})
  @records   = args[:records]
  @condition = OpenStruct.new(args[:condition])
end

Public Instance Methods

matches?() click to toggle source
# File lib/rules_processor/condition_matcher.rb, line 11
def matches?
  klass = Object.const_get(klass_name)
  klass.new(records: records, condition: condition).perform
end

Private Instance Methods

klass_name() click to toggle source
# File lib/rules_processor/condition_matcher.rb, line 18
def klass_name
  camelized_operator_name = condition.operator.split('_').collect(&:capitalize).join
  "RulesProcessor::Operations::#{camelized_operator_name}"
end