Sha256: c142bdcf550b2f4159aa7769a901a037100f9ea2ecbc5f534b7e48a07a3bdbeb

Contents?: true

Size: 931 Bytes

Versions: 14

Compression:

Stored size: 931 Bytes

Contents

class Hash
  
  # Example usage:
  #   @hash.dig(:k1)          # same as @hash[:k1]
  #   @hash.dig(:k1, :k2)     # same as @hash[:k1] && @hash[:k1][:k2]
  #   @hash.dig(:k1, :k2, k3) # same as @hash[:k1] && @hash[:k1][:k2] && @hash[:k1][:k2][:k3]
  def dig(*path)
    path.inject(self) do |location, key|
      location.respond_to?(:keys) ? location[key] : nil
    end
  end
  
  # Destructively convert all keys to strings.
  def recursive_stringify_keys!
    keys.each do |key|
      value = delete(key)
      self[key.to_s] = value.is_a?(Hash) ? value.recursive_stringify_keys! : value
    end
    self
  end
end

class Net::HTTP
  # Getting rid of the 'warning: peer certificate won't be verified in this SSL session'
  alias_method :old_initialize, :initialize
  def initialize(*args)
    old_initialize(*args)
    @ssl_context = OpenSSL::SSL::SSLContext.new
    @ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
postageapp-1.0.24 lib/postageapp/utils.rb
postageapp-1.0.23 lib/postageapp/utils.rb
postageapp-1.0.22 lib/postageapp/utils.rb
postageapp-1.0.21 lib/postageapp/utils.rb
postageapp-1.0.20 lib/postageapp/utils.rb
postageapp-1.0.19 lib/postageapp/utils.rb
postageapp-1.0.18 lib/postageapp/utils.rb
postageapp-1.0.17 lib/postageapp/utils.rb
postageapp-1.0.16 lib/postageapp/utils.rb
postageapp-1.0.15 lib/postageapp/utils.rb
postageapp-1.0.14 lib/postageapp/utils.rb
postageapp-1.0.13 lib/postageapp/utils.rb
postageapp-1.0.12 lib/postageapp/utils.rb
postageapp-1.0.11 lib/postageapp/utils.rb