Class: Sapp::Response
- Inherits:
-
Object
- Object
- Sapp::Response
- Defined in:
- lib/sapp/response.rb
Overview
In charge of creating the tuple deciding Content-Type and returning status.
Instance Attribute Summary collapse
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(status, handler) ⇒ Response
constructor
A new instance of Response.
-
#process_handler ⇒ Object
With defaults.
Constructor Details
#initialize(status, handler) ⇒ Response
Returns a new instance of Response.
9 10 11 12 13 |
# File 'lib/sapp/response.rb', line 9 def initialize status, handler @status = status @handler = handler @headers = Hash.new end |
Instance Attribute Details
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
7 8 9 |
# File 'lib/sapp/response.rb', line 7 def handler @handler end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
7 8 9 |
# File 'lib/sapp/response.rb', line 7 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/sapp/response.rb', line 7 def status @status end |
Instance Method Details
#process_handler ⇒ Object
With defaults
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sapp/response.rb', line 16 def process_handler case handler when String create_tuple 200, handler when Array handler when Hash add_header 'Content-Type', 'application/json' create_tuple 200, handler.to_json else [500, {}, ["response must be a string, tuple, or hash"]] end end |