Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/aigu/extensions/hash.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.recursive ⇒ Object
2 3 4 5 6 |
# File 'lib/aigu/extensions/hash.rb', line 2 def self.recursive new do |hash, key| hash[key] = recursive end end |
Instance Method Details
#sort_with_keys ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/aigu/extensions/hash.rb', line 14 def sort_with_keys sort.to_h.tap do |hash| hash.each_pair do |key, value| hash.merge! key => value.sort_with_keys if value.is_a?(Hash) end end end |
#symbolize_keys ⇒ Object
8 9 10 11 12 |
# File 'lib/aigu/extensions/hash.rb', line 8 def symbolize_keys reduce({}) do |memo, (key, value)| memo.merge! key.to_sym => value end end |