Sha256: 0fd73cd29e434f54821662c9add72748d831483809938274abc8a80e8913d548

Contents?: true

Size: 847 Bytes

Versions: 11

Compression:

Stored size: 847 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 stringify_keys!
    keys.each do |key|
      self[key.to_s] = delete(key)
    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

11 entries across 11 versions & 1 rubygems

Version Path
postageapp-1.0.10 lib/postageapp/utils.rb
postageapp-1.0.9 lib/postageapp/utils.rb
postageapp-1.0.8 lib/postageapp/utils.rb
postageapp-1.0.7 lib/postageapp/utils.rb
postageapp-1.0.6 lib/postageapp/utils.rb
postageapp-1.0.5 lib/postageapp/utils.rb
postageapp-1.0.4 lib/postageapp/utils.rb
postageapp-1.0.3 lib/postageapp/utils.rb
postageapp-1.0.2 lib/postageapp/utils.rb
postageapp-1.0.1 lib/postageapp/utils.rb
postageapp-1.0.0 lib/postageapp/utils.rb