Class: Tilia::Http::ResponseDecorator
- Inherits:
-
Object
- Object
- Tilia::Http::ResponseDecorator
- Includes:
- MessageDecoratorTrait, ResponseInterface
- Defined in:
- lib/tilia/http/response_decorator.rb
Overview
Response Decorator
This helper class allows you to easily create decorators for the Response object.
Instance Method Summary collapse
-
#initialize(inner) ⇒ ResponseDecorator
constructor
Constructor.
-
#status ⇒ Object
Returns the current HTTP status code.
-
#status=(status) ⇒ void
Sets the HTTP status code.
-
#status_text ⇒ String
Returns the human-readable status string.
-
#to_s ⇒ String
Serializes the request object as a string.
Methods included from MessageDecoratorTrait
#add_header, #add_headers, #body, #body=, #body_as_stream, #body_as_string, #header, #header?, #header_as_array, #headers, #http_version, #http_version=, #remove_header, #update_header, #update_headers
Methods included from MessageInterface
#add_header, #add_headers, #body, #body=, #body_as_stream, #body_as_string, #header, #header?, #header_as_array, #headers, #http_version, #http_version=, #remove_header, #update_header, #update_headers
Constructor Details
#initialize(inner) ⇒ ResponseDecorator
Constructor.
14 15 16 |
# File 'lib/tilia/http/response_decorator.rb', line 14 def initialize(inner) @inner = inner end |
Instance Method Details
#status ⇒ Object
Returns the current HTTP status code.
21 22 23 |
# File 'lib/tilia/http/response_decorator.rb', line 21 def status @inner.status end |
#status=(status) ⇒ void
This method returns an undefined value.
Sets the HTTP status code.
This can be either the full HTTP status code with human readable string, for example: “403 I can’t let you do that, Dave”.
Or just the code, in which case the appropriate default message will be added.
44 45 46 |
# File 'lib/tilia/http/response_decorator.rb', line 44 def status=(status) @inner.status = status end |
#status_text ⇒ String
Returns the human-readable status string.
In the case of a 200, this may for example be ‘OK’.
30 31 32 |
# File 'lib/tilia/http/response_decorator.rb', line 30 def status_text @inner.status_text end |
#to_s ⇒ String
Serializes the request object as a string.
This is useful for debugging purposes.
53 54 55 |
# File 'lib/tilia/http/response_decorator.rb', line 53 def to_s @inner.to_s end |