Sha256: 38f35fe6d4296708bf0f2e783b76216cc90678be7b484f6ec0608286cf02f6fa

Contents?: true

Size: 806 Bytes

Versions: 26

Compression:

Stored size: 806 Bytes

Contents

class Hash
  def slice(*keep_keys)
    h = {}
    keep_keys.each { |key| h[key] = fetch(key) if has_key?(key) }
    h
  end unless Hash.method_defined?(:slice)

  def except(*less_keys)
    slice(*keys - less_keys)
  end unless Hash.method_defined?(:except)

  def deep_symbolize_keys
    inject({}) { |result, (key, value)|
      value = value.deep_symbolize_keys if value.is_a?(Hash)
      result[(key.to_sym rescue key) || key] = value
      result
    }
  end unless Hash.method_defined?(:deep_symbolize_keys)

  # deep_merge_hash! 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
  
  def deep_merge!(data)
    merge!(data, &MERGER)
  end unless Hash.method_defined?(:deep_merge!)
end

Version data entries

26 entries across 24 versions & 7 rubygems

Version Path
mumukit-content-type-1.12.1 vendor/bundle/ruby/2.7.0/gems/i18n-0.9.5/lib/i18n/core_ext/hash.rb
mumukit-content-type-1.12.0 vendor/bundle/ruby/2.7.0/gems/i18n-0.9.5/lib/i18n/core_ext/hash.rb
mumukit-content-type-1.11.1 vendor/bundle/ruby/2.6.0/gems/i18n-0.9.5/lib/i18n/core_ext/hash.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/i18n-0.9.5/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/i18n-1.1.1/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/i18n-1.1.1/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/i18n-1.1.1/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/i18n-1.1.1/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/i18n-1.1.1/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/i18n-1.1.1/lib/i18n/core_ext/hash.rb
cocoapods-dependency-html-0.0.2 vendor/bundle/gems/i18n-0.9.5/lib/i18n/core_ext/hash.rb
cocoapods-dependency-html-0.0.1 vendor/bundle/gems/i18n-0.9.5/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/i18n-1.1.1/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/i18n-1.1.1/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/i18n-1.1.1/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/i18n-1.1.1/lib/i18n/core_ext/hash.rb
i18n-1.1.1 lib/i18n/core_ext/hash.rb
i18n-1.1.0 lib/i18n/core_ext/hash.rb
monero_wallet_gen-0.1.0 vendor/bundle/ruby/2.3.0/gems/i18n-1.0.1/lib/i18n/core_ext/hash.rb
i18n-1.0.1 lib/i18n/core_ext/hash.rb