Class: Storexplore::HashUtils
- Inherits:
-
Object
- Object
- Storexplore::HashUtils
- Defined in:
- lib/storexplore/hash_utils.rb
Class Method Summary collapse
- .contains?(hash, other) ⇒ Boolean
- .internalize_keys(hash) ⇒ Object
- .stringify_keys(hash) ⇒ Object
- .without(hash, keys) ⇒ Object
Class Method Details
.contains?(hash, other) ⇒ Boolean
28 29 30 31 32 |
# File 'lib/storexplore/hash_utils.rb', line 28 def self.contains?(hash,other) other.all? do |key, value| hash.include?(key) && hash[key] == value end end |
.internalize_keys(hash) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/storexplore/hash_utils.rb', line 48 def self.internalize_keys(hash) result = {} hash.each do |key, value| result[key.intern] = value end result end |
.stringify_keys(hash) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/storexplore/hash_utils.rb', line 40 def self.stringify_keys(hash) result = {} hash.each do |key, value| result[key.to_s] = value end result end |
.without(hash, keys) ⇒ Object
34 35 36 37 38 |
# File 'lib/storexplore/hash_utils.rb', line 34 def self.without(hash,keys) hash.reject do |key, value| keys.include?(key) end end |