Class: RR::WildcardMatchers::HashIncluding
- Inherits:
-
Object
- Object
- RR::WildcardMatchers::HashIncluding
- Defined in:
- lib/rr/wildcard_matchers/hash_including.rb
Instance Attribute Summary (collapse)
-
- (Object) expected_hash
readonly
Returns the value of attribute expected_hash.
Instance Method Summary (collapse)
- - (Object) ==(other) (also: #eql?)
-
- (HashIncluding) initialize(expected_hash)
constructor
A new instance of HashIncluding.
- - (Object) inspect
- - (Boolean) wildcard_match?(other)
Constructor Details
- (HashIncluding) initialize(expected_hash)
A new instance of HashIncluding
6 7 8 |
# File 'lib/rr/wildcard_matchers/hash_including.rb', line 6 def initialize(expected_hash) @expected_hash = expected_hash.clone end |
Instance Attribute Details
- (Object) expected_hash (readonly)
Returns the value of attribute expected_hash
4 5 6 |
# File 'lib/rr/wildcard_matchers/hash_including.rb', line 4 def expected_hash @expected_hash end |
Instance Method Details
- (Object) ==(other) Also known as: eql?
22 23 24 25 |
# File 'lib/rr/wildcard_matchers/hash_including.rb', line 22 def ==(other) return false unless other.is_a?(self.class) self.expected_hash == other.expected_hash end |
- (Object) inspect
18 19 20 |
# File 'lib/rr/wildcard_matchers/hash_including.rb', line 18 def inspect "hash_including(#{expected_hash.inspect})" end |
- (Boolean) wildcard_match?(other)
10 11 12 13 14 15 16 |
# File 'lib/rr/wildcard_matchers/hash_including.rb', line 10 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 |