Sha256: 7300af56675971de8902c52c75fe197872df6745424ef4ac566817db7a537a50

Contents?: true

Size: 497 Bytes

Versions: 4

Compression:

Stored size: 497 Bytes

Contents

module Fakes
  class CombinedArgMatcher
    attr_reader :all_matchers

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

    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

    def add(matcher)
      all_matchers << matcher
    end
    alias :<< :add
    
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fakes-1.1.6 lib/fakes/arg_matching/combined_arg_matcher.rb
fakes-1.1.5 lib/fakes/arg_matching/combined_arg_matcher.rb
fakes-1.1.4 lib/fakes/arg_matching/combined_arg_matcher.rb
fakes-1.1.3 lib/fakes/arg_matching/combined_arg_matcher.rb