Class: Fakes::CombinedArgMatcher
- Inherits:
-
Object
- Object
- Fakes::CombinedArgMatcher
- Defined in:
- lib/fakes/arg_matching/combined_arg_matcher.rb
Instance Attribute Summary collapse
-
#all_matchers ⇒ Object
readonly
Returns the value of attribute all_matchers.
Instance Method Summary collapse
- #add(matcher) ⇒ Object (also: #<<)
-
#initialize(options = {}) ⇒ CombinedArgMatcher
constructor
A new instance of CombinedArgMatcher.
- #matches?(args) ⇒ Boolean
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( = {}) @all_matchers = .fetch(:matchers,[]) end |
Instance Attribute Details
#all_matchers ⇒ Object (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
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 |