Module: Webbed::Helpers::RackResponseHelper::InstanceMethods

Defined in:
lib/webbed/helpers/rack_response_helper.rb

Instance Method Summary collapse

Instance Method Details

#to_aArray

Note:

This will not return a Rack-compatible response array.

Converts the Response to an array.

The array has a similar format to the format defined in the Rack specification with some modifications:

  1. The Reason Phrase is included with the Status Code.
  2. The Entity Body does not need to respond to #each.

Returns:

  • (Array)

See Also:



43
44
45
# File 'lib/webbed/helpers/rack_response_helper.rb', line 43

def to_a
  ["#{status_code} #{reason_phrase}", headers, entity_body]
end

#to_rackArray

Note:

Due to limitations in Rack, Reason Phrases are not included in the array.

Converts the Response to a Rack response array.

The array has the same format as that defined in the Rack specification.

Returns:

  • (Array)


25
26
27
28
29
30
31
# File 'lib/webbed/helpers/rack_response_helper.rb', line 25

def to_rack
  if entity_body.respond_to?(:each)
    [status_code.to_i, headers, entity_body]
  else
    [status_code.to_i, headers, [entity_body]]
  end
end