Module: HashHelper::DeepNormalize
- Included in:
- Hash
- Defined in:
- lib/hash_helper/deep_normalize.rb
Instance Method Summary collapse
-
#deep_normalize(default_value: nil) ⇒ Hash
Recursively normalizes the hash by merging it with a default structure.
Instance Method Details
#deep_normalize(default_value: nil) ⇒ Hash
Recursively normalizes the hash by merging it with a default structure.
This method creates a nested default structure based on the keys of the hash, assigning each key a specified default value. The resulting structure is then deeply merged with the original hash.
20 21 22 |
# File 'lib/hash_helper/deep_normalize.rb', line 20 def deep_normalize(default_value: nil) build_default(self, default_value: default_value).deep_merge(self) end |