module Mappru::Ext::HashExt

Public Instance Methods

sort_pair() click to toggle source
# 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!() click to toggle source
# File lib/mappru/ext/hash_ext.rb, line 13
def sort_pair!
  self.replace(self.sort_pair)
end
without_nil() click to toggle source
# 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