class Hash

Public Instance Methods

reverse_significant_merge(other_hash={}) click to toggle source

need to call significant on self now.

# File lib/significance/core_ext/hash.rb, line 19
def reverse_significant_merge(other_hash={})
  return significant if (other_hash ||= {}).blank?
  significant.reverse_merge(other_hash)
end
reverse_significant_merge!(other_hash={}) click to toggle source

or keep_significant for destructive

# File lib/significance/core_ext/hash.rb, line 24
def reverse_significant_merge!(other_hash={})
  return keep_significant if (other_hash ||= {}).blank?
  keep_significant.reverse_merge!(other_hash)
end
significant() click to toggle source
# File lib/significance/core_ext/hash.rb, line 4
def significant
  Hash.new.tap { |hsh| each(&significance_each_block(hsh)) }
end
significant_merge(other_hash={}) click to toggle source

also allows nil so we don’t need Something.new(params.merge(params || {}))

# File lib/significance/core_ext/hash.rb, line 9
def significant_merge(other_hash={})
  return self unless (other_hash ||= {}).significant.present?
  merge(other_hash.significant)
end
significant_merge!(other_hash={}) click to toggle source

destructive

# File lib/significance/core_ext/hash.rb, line 14
def significant_merge!(other_hash={})
  return self unless (other_hash ||= {}).significant.present?
  merge!(other_hash.significant)
end

Private Instance Methods

significance_each_block(hsh={}) click to toggle source
# File lib/significance/core_ext/hash.rb, line 32
def significance_each_block(hsh={})
  Proc.new { |k, v| v.significant_significance.tap { |res| res and hsh[k] = res } }
end