class HTTP::Headers
def coerce(object)
-
(Headers)
-
Parameters:
-
object
(#to_hash, #to_h, #to_a
) --
Raises:
-
(Error)
- if object can't be coerced
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