Class: Darthjee::CoreExt::Hash::Squasher Private
- Defined in:
- lib/darthjee/core_ext/hash/squasher.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
class responsible for squashing a hash
Instance Method Summary collapse
-
#initialize(joiner = '.') ⇒ Squasher
constructor
private
A new instance of Squasher.
-
#squash(hash) ⇒ ::Hash
private
Squash a hash creating a new hash.
Constructor Details
#initialize(joiner = '.') ⇒ Squasher
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Squasher.
19 20 21 |
# File 'lib/darthjee/core_ext/hash/squasher.rb', line 19 def initialize(joiner = '.') @joiner = joiner end |
Instance Method Details
#squash(hash) ⇒ ::Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Squash a hash creating a new hash
Squash the hash so that it becomes a single level hash merging the keys of outter and inner hashes
68 69 70 71 72 73 74 75 76 |
# File 'lib/darthjee/core_ext/hash/squasher.rb', line 68 def squash(hash) hash.keys.each do |key| next unless hash[key].is_any?(Hash, Array) value = hash.delete(key) add_value_to_hash(hash, key, value) end hash end |