Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/delphix/utils.rb
Instance Method Summary collapse
-
#normalize_keys ⇒ Hash
Returns a new hash with all keys downcased and converted to symbols.
-
#recursively_normalize_keys ⇒ Hash
Returns a new Hash, recursively downcasing and converting all keys to symbols.
-
#recursively_transform_keys(&block) ⇒ Hash
Returns a new hash, recursively converting all keys by the block operation.
-
#transform_keys ⇒ Hash
Returns a new hash with all keys converted using the block operation.
Instance Method Details
#normalize_keys ⇒ Hash
Returns a new hash with all keys downcased and converted to symbols.
57 58 59 |
# File 'lib/delphix/utils.rb', line 57 def normalize_keys transform_keys { |key| key.downcase.to_sym rescue key } end |
#recursively_normalize_keys ⇒ Hash
Returns a new Hash, recursively downcasing and converting all keys to symbols.
66 67 68 |
# File 'lib/delphix/utils.rb', line 66 def recursively_normalize_keys recursively_transform_keys { |key| key.downcase.to_sym rescue key } end |
#recursively_transform_keys(&block) ⇒ Hash
Returns a new hash, recursively converting all keys by the block operation.
94 95 96 |
# File 'lib/delphix/utils.rb', line 94 def recursively_transform_keys(&block) _recursively_transform_keys_in_object(self, &block) end |
#transform_keys ⇒ Hash
Returns a new hash with all keys converted using the block operation.
80 81 82 83 84 85 86 87 |
# File 'lib/delphix/utils.rb', line 80 def transform_keys enum_for(:transform_keys) unless block_given? result = self.class.new each_key do |key| result[yield(key)] = self[key] end result end |