Class: HttpStub::Models::HashWithRegexpableValues

Inherits:
Hash
  • Object
show all
Defined in:
lib/http_stub/models/hash_with_regexpable_values.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ HashWithRegexpableValues

Returns a new instance of HashWithRegexpableValues.



6
7
8
# File 'lib/http_stub/models/hash_with_regexpable_values.rb', line 6

def initialize(hash)
  hash.each_pair { |key, value| self[key] = HttpStub::Models::RegexpableValue.new(value) }
end

Instance Method Details

#match?(other_hash) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
# File 'lib/http_stub/models/hash_with_regexpable_values.rb', line 10

def match?(other_hash)
  !(self.find do |key_and_regexpable_value|
    other_value = other_hash[key_and_regexpable_value[0]]
    !(other_value && key_and_regexpable_value[1].match?(other_value))
  end)
end