gems/ruby/2.2.0/gems/http-0.7.1/lib/http/headers.rb
# Coerces given `object` into Headers.
#
# @raise [Error] if object can't be coerced
# @param [#to_hash, #to_h, #to_a] object
# @return [Headers]
Coerces given `object` into Headers.
Coerces given ` object ` into Headers .
def coerce(object)
        unless object.is_a? self
          object = case
                   when object.respond_to?(:to_hash) then object.to_hash
                   when object.respond_to?(:to_h)    then object.to_h
                   when object.respond_to?(:to_a)    then object.to_a
                   else fail Error, "Can't coerce #{object.inspect} to Headers"
                   end
        end
        headers = new
        object.each { |k, v| headers.add k, v }
        headers
      end
def coerce ( object ) unless object . is_a? self object = case when object . respond_to? ( :to_hash ) then object . to_hash when object . respond_to? ( :to_h ) then object . to_h when object . respond_to? ( :to_a ) then object . to_a else fail Error , "Can't coerce #{object.inspect} to Headers" end end headers = new object . each { | k , v | headers . add k , v } headers end
Coerces given `object` into Headers.
Coerces given ` object ` into Headers .
None
Headers
[Error] if object can't be coerced
[ Error ] if object can ' t be coerced
object
<not_specific>
<not_specific>
None