Sha256: 5dd7f9af123e05aafe46bbbfdf6771053863ef2f7ecc97b4d76cb6bb196cfda9

Contents?: true

Size: 692 Bytes

Versions: 56

Compression:

Stored size: 692 Bytes

Contents

module RR
  module WildcardMatchers
    class HashIncluding
      attr_reader :expected_hash

      def initialize(expected_hash)
        @expected_hash = expected_hash.clone
      end

      def wildcard_match?(other)
        return true if self == other
        expected_hash.each_pair do |key, value|
          return false unless other.has_key?(key) && other[key] == expected_hash[key]
        end
        return true
      end

      def inspect
        "hash_including(#{expected_hash.inspect})"
      end

      def ==(other)
        return false unless other.is_a?(self.class)
        self.expected_hash == other.expected_hash
      end
      alias_method :eql?, :==
    end
  end
end

Version data entries

56 entries across 52 versions & 9 rubygems

Version Path
adva-0.2.4 test/rr/lib/rr/wildcard_matchers/hash_including.rb
adva-0.2.3 test/rr/lib/rr/wildcard_matchers/hash_including.rb
adva-0.2.2 test/rr/lib/rr/wildcard_matchers/hash_including.rb
adva-0.2.1 test/rr/lib/rr/wildcard_matchers/hash_including.rb
adva-0.2.0 test/rr/lib/rr/wildcard_matchers/hash_including.rb
adva-0.1.4 test/rr/lib/rr/wildcard_matchers/hash_including.rb
adva-0.1.3 test/rr/lib/rr/wildcard_matchers/hash_including.rb
adva-0.1.2 test/rr/lib/rr/wildcard_matchers/hash_including.rb
adva-0.1.1 test/rr/lib/rr/wildcard_matchers/hash_including.rb
adva-0.1.0 test/rr/lib/rr/wildcard_matchers/hash_including.rb
adva-0.0.1 test/rr/lib/rr/wildcard_matchers/hash_including.rb
jferris-rr-0.7.1.0.1239654108 lib/rr/wildcard_matchers/hash_including.rb
redinger-redinger-rr-0.10.3 lib/rr/wildcard_matchers/hash_including.rb
redinger-rr-0.10.4 lib/rr/wildcard_matchers/hash_including.rb
rr-1.0.5 lib/rr/wildcard_matchers/hash_including.rb
rr-1.0.5.rc2 lib/rr/wildcard_matchers/hash_including.rb
rr-1.0.5.rc1 lib/rr/wildcard_matchers/hash_including.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.3/vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/wildcard_matchers/hash_including.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/wildcard_matchers/hash_including.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/wildcard_matchers/hash_including.rb