Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/futurism/shims/deep_transform_values.rb
Instance Method Summary collapse
-
#deep_transform_values(&block) ⇒ Object
Returns a new hash with all values converted by the block operation.
-
#deep_transform_values!(&block) ⇒ Object
Destructively converts all values by using the block operation.
Instance Method Details
#deep_transform_values(&block) ⇒ Object
Returns a new hash with all values converted by the block operation. This includes the values from the root hash and from all nested hashes and arrays.
hash = { person: { name: 'Rob', age: '28' } }
hash.deep_transform_values{ |value| value.to_s.upcase }
# => {person: {name: "ROB", age: "28"}}
12 13 14 |
# File 'lib/futurism/shims/deep_transform_values.rb', line 12 def deep_transform_values(&block) _deep_transform_values_in_object(self, &block) end |
#deep_transform_values!(&block) ⇒ Object
Destructively converts all values by using the block operation. This includes the values from the root hash and from all nested hashes and arrays.
19 20 21 |
# File 'lib/futurism/shims/deep_transform_values.rb', line 19 def deep_transform_values!(&block) _deep_transform_values_in_object!(self, &block) end |