Class: CaseGen::ExpectRule

Inherits:
Object
  • Object
show all
Includes:
ComboMatcher
Defined in:
lib/case_gen/expect_rule.rb

Instance Method Summary collapse

Methods included from ComboMatcher

#ignore_keys, #matches_criteria

Constructor Details

#initialize(rule_data) ⇒ ExpectRule

Returns a new instance of ExpectRule.



7
8
9
# File 'lib/case_gen/expect_rule.rb', line 7

def initialize(rule_data)
  @rule_data = rule_data
end

Instance Method Details

#apply(combos) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/case_gen/expect_rule.rb', line 11

def apply(combos)
  combos.each do |combo|
    expect_keys = combo.names.select { |name| combo.send(name) == :expect }
    next if expect_keys.none?

    next unless matches_criteria(combo, expect_keys)

    expect_keys.each do |expect_key|
      combo.send("#{expect_key}=", @rule_data[expect_key])
    end
  end
end