Module: HttpStub::Extensions::Core::Hash

Defined in:
lib/http_stub/extensions/core/hash.rb

Instance Method Summary collapse

Instance Method Details

#downcase_and_underscore_keysObject



7
8
9
10
11
12
# File 'lib/http_stub/extensions/core/hash.rb', line 7

def downcase_and_underscore_keys
  self.reduce({}) do |result, element|
    result[element[0].is_a?(::String) ? element[0].downcase.gsub(/-/, '_') : element[0]] = element[1]
    result
  end
end

#has_hash?(other_hash) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/http_stub/extensions/core/hash.rb', line 14

def has_hash?(other_hash)
  other_hash.nil? || other_hash.reduce(true) do |result, element|
    result && (self[element[0]] == element[1])
  end
end

#with_indifferent_and_insensitive_accessObject



20
21
22
# File 'lib/http_stub/extensions/core/hash.rb', line 20

def with_indifferent_and_insensitive_access
  HttpStub::HashWithIndifferentAndInsensitiveAccess.new(self)
end