Method: M2R::Headers#initialize

Defined in:
lib/m2r/headers.rb

#initialize(hash = {}, compatible = false) ⇒ Headers

Returns a new instance of Headers.

Parameters:

  • hash (Hash, #inject) (defaults to: {})

    Collection of headers

  • compatible (true, false) (defaults to: false)

    Whether the hash already contains downcased strings only. If so it is going to be directly as container for the headers.



13
14
15
16
17
18
19
# File 'lib/m2r/headers.rb', line 13

def initialize(hash = {}, compatible = false)
  @headers = hash and return if compatible
  @headers = hash.inject({}) do |headers,(header,value)|
    headers[transform_key(header)] = value
    headers
  end
end