class RulesProcessor::RuleMatcher

Attributes

options[RW]
records[RW]
rule[RW]

Public Class Methods

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

Public Instance Methods

matches?() click to toggle source
# File lib/rules_processor/rule_matcher.rb, line 12
def matches?
  return false if both_condition_group_empty?
  meet_all_matches? || meet_any_matches?
end

Private Instance Methods

both_condition_group_empty?() click to toggle source
# File lib/rules_processor/rule_matcher.rb, line 19
def both_condition_group_empty?
  rule.meet_all.empty? && rule.meet_any.empty?
end
condition_matcher(condition) click to toggle source
# File lib/rules_processor/rule_matcher.rb, line 33
def condition_matcher(condition)
  RulesProcessor::ConditionMatcher.new(records: records, options: options, condition: condition)
end
meet_all_matches?() click to toggle source
# File lib/rules_processor/rule_matcher.rb, line 23
def meet_all_matches?
  return false if rule.meet_all.empty?
  rule.meet_all.all? { |c| condition_matcher(c).matches? }
end
meet_any_matches?() click to toggle source
# File lib/rules_processor/rule_matcher.rb, line 28
def meet_any_matches?
  return false if rule.meet_any.empty?
  rule.meet_any.any? { |c| condition_matcher(c).matches? }
end