Sha256: 34fdbeae784e57bff5a22bc7ea3ea6316dfa1995dc3dcf5adc19f572af817bc0

Contents?: true

Size: 789 Bytes

Versions: 358

Compression:

Stored size: 789 Bytes

Contents

class Hash
  def slice(*keep_keys)
    h = {}
    keep_keys.each { |key| h[key] = fetch(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

358 entries across 321 versions & 65 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/i18n-0.6.9/lib/i18n/core_ext/hash.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/i18n-0.6.9/lib/i18n/core_ext/hash.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/i18n-0.6.9/lib/i18n/core_ext/hash.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/i18n-0.6.9/lib/i18n/core_ext/hash.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/i18n-0.6.9/lib/i18n/core_ext/hash.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/i18n-0.6.9/lib/i18n/core_ext/hash.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/i18n-0.6.9/lib/i18n/core_ext/hash.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/i18n-0.6.9/lib/i18n/core_ext/hash.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/i18n-0.6.9/lib/i18n/core_ext/hash.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/i18n-0.6.9/lib/i18n/core_ext/hash.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/i18n-0.6.9/lib/i18n/core_ext/hash.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/i18n-0.6.9/lib/i18n/core_ext/hash.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/i18n-0.6.9/lib/i18n/core_ext/hash.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/i18n-0.6.9/lib/i18n/core_ext/hash.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/i18n-0.6.9/lib/i18n/core_ext/hash.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/i18n-0.6.9/lib/i18n/core_ext/hash.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/i18n-0.6.9/lib/i18n/core_ext/hash.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/i18n-0.6.9/lib/i18n/core_ext/hash.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/i18n-0.6.9/lib/i18n/core_ext/hash.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/i18n-0.6.9/lib/i18n/core_ext/hash.rb