Sha256: 7b2e3dbfb7a315f90146ffbd9d7e598a8a626cb936c46d60fdecf6af5221f9be
Contents?: true
Size: 739 Bytes
Versions: 2
Compression:
Stored size: 739 Bytes
Contents
module I18n module JS module Utils # deep_merge by Stefan Rusterholz, see <http://www.ruby-forum.com/topic/142809>. MERGER = proc do |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &MERGER) : v2 end HASH_NIL_VALUE_CLEANER_PROC = proc do |k, v| v.kind_of?(Hash) ? (v.delete_if(&HASH_NIL_VALUE_CLEANER_PROC); false) : v.nil? end def self.strip_keys_with_nil_values(hash) hash.dup.delete_if(&HASH_NIL_VALUE_CLEANER_PROC) end def self.deep_merge(target_hash, hash) # :nodoc: target_hash.merge(hash, &MERGER) end def self.deep_merge!(target_hash, hash) # :nodoc: target_hash.merge!(hash, &MERGER) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
i18n-js-3.0.0.rc8 | lib/i18n/js/utils.rb |
i18n-js-3.0.0.rc7 | lib/i18n/js/utils.rb |