Sha256: dfa64e6fe6d90ead47ea54686444b8880c6176508969965feac2d22aeaa1c80e
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
class Hash # Ruby 2.3.0 adds the dig method so this needs to be conditional. unless ((instance_methods & [ :dig ]).any?) # 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 end unless ((instance_methods & [ :recursive_stringify_keys! ]).any?) # Destructively convert all keys to strings. def recursive_stringify_keys! keys.each do |key| value = delete(key) self[key.to_s] = case (value) when Hash value.recursive_stringify_keys! else value end end self end end end class Net::HTTP # Getting rid of the 'warning: peer certificate won't be verified in this SSL session' alias_method :__initialize, :initialize def initialize(*args) __initialize(*args) @ssl_context = OpenSSL::SSL::SSLContext.new @ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
postageapp-1.2.6 | lib/postageapp/utils.rb |
postageapp-1.2.5 | lib/postageapp/utils.rb |