Module: Leafy::Utils
- Defined in:
- lib/leafy/utils.rb
Class Method Summary collapse
Class Method Details
.stringify_keys(hash) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/leafy/utils.rb', line 10 def self.stringify_keys(hash) hash.dup.to_a.map do |pair| key, value = pair [key.to_s, value.is_a?(Hash) ? Leafy::Utils.stringify_keys(value) : value] end.to_h end |
.symbolize_keys(hash) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/leafy/utils.rb', line 3 def self.symbolize_keys(hash) hash.dup.to_a.map do |pair| key, value = pair [key.to_sym, value.is_a?(Hash) ? Leafy::Utils.symbolize_keys(value) : value] end.to_h end |