Module: Webbed::Helpers::RackResponseHelper
- Included in:
- Response
- Defined in:
- lib/webbed/helpers/rack_response_helper.rb
Overview
Response helper for converting Responses into Rack response arrays
Instance Method Summary (collapse)
-
- (Array) to_a
Converts the Response to an array.
-
- (Array) to_rack
Converts the Response to a Rack response array.
Instance Method Details
- (Array) to_a
Note:
This will not return a Rack-compatible response array.
Converts the Response to an array
The array has the same format as the one that you use in order to create a Response.
28 29 30 |
# File 'lib/webbed/helpers/rack_response_helper.rb', line 28 def to_a ["#{status_code} #{reason_phrase}", headers, entity_body] end |
- (Array) to_rack
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.
12 13 14 15 16 17 18 |
# File 'lib/webbed/helpers/rack_response_helper.rb', line 12 def to_rack if entity_body.respond_to?(:each) [status_code, headers, entity_body] else [status_code, headers, [entity_body]] end end |