Class: ApiTransformer::FrontendResponse
- Inherits:
-
Object
- Object
- ApiTransformer::FrontendResponse
- Defined in:
- lib/api_transformer/frontend_response.rb
Overview
Container for frontend response data
Instance Attribute Summary collapse
- #body ⇒ Object
-
#content_type ⇒ Object
writeonly
Sets the attribute content_type.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #headers ⇒ Object
-
#initialize ⇒ FrontendResponse
constructor
A new instance of FrontendResponse.
- #set(key, value) ⇒ Object
- #set_cookie(key, value) ⇒ Object
- #set_header(key, value) ⇒ Object
Constructor Details
#initialize ⇒ FrontendResponse
Returns a new instance of FrontendResponse.
9 10 11 12 13 |
# File 'lib/api_transformer/frontend_response.rb', line 9 def initialize @hash = {} = {} @headers = {} end |
Instance Attribute Details
#body ⇒ Object
27 28 29 |
# File 'lib/api_transformer/frontend_response.rb', line 27 def body @hash.any? && @hash.to_json || @body end |
#content_type=(value) ⇒ Object
Sets the attribute content_type
7 8 9 |
# File 'lib/api_transformer/frontend_response.rb', line 7 def content_type=(value) @content_type = value end |
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/api_transformer/frontend_response.rb', line 6 def status @status end |
Instance Method Details
#headers ⇒ Object
31 32 33 |
# File 'lib/api_transformer/frontend_response.rb', line 31 def headers [@headers, , content_type_header].reduce(&:merge) end |
#set(key, value) ⇒ Object
15 16 17 |
# File 'lib/api_transformer/frontend_response.rb', line 15 def set(key, value) @hash[key] = value end |
#set_cookie(key, value) ⇒ Object
19 20 21 |
# File 'lib/api_transformer/frontend_response.rb', line 19 def (key, value) [key] = value end |
#set_header(key, value) ⇒ Object
23 24 25 |
# File 'lib/api_transformer/frontend_response.rb', line 23 def set_header(key, value) @headers[key] = value end |