Class: Fakes::CombinedArgMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/fakes/arg_matching/combined_arg_matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CombinedArgMatcher

Returns a new instance of CombinedArgMatcher.



5
6
7
# File 'lib/fakes/arg_matching/combined_arg_matcher.rb', line 5

def initialize(options = {})
  @all_matchers = options.fetch(:matchers,[])
end

Instance Attribute Details

#all_matchersObject (readonly)

Returns the value of attribute all_matchers.



3
4
5
# File 'lib/fakes/arg_matching/combined_arg_matcher.rb', line 3

def all_matchers
  @all_matchers
end

Instance Method Details

#add(matcher) ⇒ Object Also known as: <<



21
22
23
# File 'lib/fakes/arg_matching/combined_arg_matcher.rb', line 21

def add(matcher)
  all_matchers << matcher
end

#matches?(args) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fakes/arg_matching/combined_arg_matcher.rb', line 9

def matches?(args)
  matches = true

  all_matchers.each_with_index do |matcher, index|
    value = args[index]
    matches &= matcher.matches?(value)
    return false unless matches
  end

  matches
end