Class: BloodContracts::Contracts::Matcher

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/blood_contracts/contracts/matcher.rb

Instance Method Summary collapse

Instance Method Details

#call(input, output, meta = Hash.new, storage:) {|rule_names, options| ... } ⇒ Object

Yields:

  • (rule_names, options)


8
9
10
11
12
13
14
15
16
17
18
# File 'lib/blood_contracts/contracts/matcher.rb', line 8

def call(input, output, meta = Hash.new, storage:)
  options = Hashie::Mash.new(input: input, output: output, meta: meta)

  rule_names = select_matched_rules!(options).keys
  rule_names = [Storage::UNDEFINED_RULE] if rule_names.empty?
  Array(rule_names).each(&storage.method(:store))

  yield rule_names, options if block_given?

  !storage.found_unexpected_behavior?
end