Class: RulesProcessor::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/rules_processor/processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Processor

Returns a new instance of Processor.



6
7
8
9
10
# File 'lib/rules_processor/processor.rb', line 6

def initialize(args = {})
  @records = args[:records]
  @ruleset = args[:ruleset]
  @options = args[:options]
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/rules_processor/processor.rb', line 4

def options
  @options
end

#recordsObject

Returns the value of attribute records.



4
5
6
# File 'lib/rules_processor/processor.rb', line 4

def records
  @records
end

#rulesetObject

Returns the value of attribute ruleset.



4
5
6
# File 'lib/rules_processor/processor.rb', line 4

def ruleset
  @ruleset
end

Instance Method Details

#processObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rules_processor/processor.rb', line 12

def process
  ruleset.each do |rule|
    mark_skipped(rule) && next if already_matched?(rule)
    mark_not_match(rule) && next unless rule_matches?(rule)

    mark_match(rule) && actions_processor(rule)

    process
    break
  end
  matching_result
end