Module: Dapp::CoreExt::Hash
- Defined in:
- lib/dapp/core_ext/hash.rb
Instance Method Summary collapse
-
#in_depth_merge(hash) ⇒ Object
do not conflict with activesupport`s deep_merge.
- #symbolize_keys ⇒ Object
Instance Method Details
#in_depth_merge(hash) ⇒ Object
do not conflict with activesupport`s deep_merge
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/dapp/core_ext/hash.rb', line 4 def in_depth_merge(hash) # do not conflict with activesupport`s deep_merge merge(hash) do |_, v1, v2| if v1.is_a?(::Hash) && v2.is_a?(::Hash) v1.in_depth_merge(v2) elsif v1.is_a?(::Array) || v2.is_a?(::Array) [v1, v2].flatten else v2 end end end |
#symbolize_keys ⇒ Object
16 17 18 |
# File 'lib/dapp/core_ext/hash.rb', line 16 def symbolize_keys transform_keys { |key| key.to_sym rescue key } end |