Sha256: 98f65e2545a059cbd9779490608fc1906cfdfb10627d627b93e7f68e449613d1

Contents?: true

Size: 816 Bytes

Versions: 47

Compression:

Stored size: 816 Bytes

Contents

class Hash
  def slice(*keep_keys)
    h = self.class.new
    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

47 entries across 42 versions & 8 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/i18n-0.8.0/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/i18n-0.8.0/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/i18n-0.8.0/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/i18n-0.8.0/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/i18n-0.8.0/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/i18n-0.8.0/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.1.4.0 vendor/bundle/ruby/2.5.0/gems/i18n-0.8.0/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.1.2.0 vendor/bundle/ruby/2.3.0/gems/i18n-0.8.0/lib/i18n/core_ext/hash.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/i18n-0.8.0/lib/i18n/core_ext/hash.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/i18n-0.8.0/lib/i18n/core_ext/hash.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/i18n-0.8.0/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.1.1.0 vendor/bundle/ruby/2.5.0/gems/i18n-0.8.0/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.0.4.0 vendor/bundle/ruby/2.5.0/gems/i18n-0.8.0/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.0.3.0 vendor/bundle/ruby/2.5.0/gems/i18n-0.8.0/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.5.0/gems/i18n-0.8.0/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.4.0/gems/i18n-0.8.0/lib/i18n/core_ext/hash.rb
pract6-0.1.0 .gem/ruby/2.3.0/gems/i18n-0.8.6/lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.0.1.0 vendor/bundle/ruby/2.4.0/gems/i18n-0.8.0/lib/i18n/core_ext/hash.rb
i18n-0.9.0 lib/i18n/core_ext/hash.rb
vagrant-unbundled-2.0.0.1 vendor/bundle/ruby/2.4.0/gems/i18n-0.8.0/lib/i18n/core_ext/hash.rb