Module: Webbed::Helpers::RackResponseHelper::InstanceMethods
- Defined in:
- lib/webbed/helpers/rack_response_helper.rb
Instance Method Summary collapse
-
#to_a ⇒ Array
Converts the Response to an array.
-
#to_rack ⇒ Array
Converts the Response to a Rack response array.
Instance Method Details
#to_a ⇒ Array
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:
- The Reason Phrase is included with the Status Code.
- The Entity Body does not need to respond to
#each
.
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_rack ⇒ Array
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.
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 |