Module: Mappru::Ext::HashExt
- Defined in:
- lib/mappru/ext/hash_ext.rb
Instance Method Summary collapse
Instance Method Details
#sort_pair ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/mappru/ext/hash_ext.rb', line 3 def sort_pair new_hash = {} self.sort_by(&:to_s).each do |k, v| new_hash[k] = v end new_hash end |
#sort_pair! ⇒ Object
13 14 15 |
# File 'lib/mappru/ext/hash_ext.rb', line 13 def sort_pair! self.replace(self.sort_pair) end |
#without_nil ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/mappru/ext/hash_ext.rb', line 17 def without_nil new_hash = {} self.each do |k, v| new_hash[k] = v if v end new_hash end |