Class: Tamashii::Server::Response
- Inherits:
-
Rack::Response
- Object
- Rack::Response
- Tamashii::Server::Response
- Defined in:
- lib/tamashii/server/response.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(body = {}, status = 200, header = {}, &block) ⇒ Response
constructor
A new instance of Response.
- #process_body(body) ⇒ Object
- #process_header(header, body) ⇒ Object
Constructor Details
#initialize(body = {}, status = 200, header = {}, &block) ⇒ Response
Returns a new instance of Response.
9 10 11 12 13 |
# File 'lib/tamashii/server/response.rb', line 9 def initialize(body = {}, status = 200, header = {}, &block) body = process_body(body) header = process_header(header, body.first) super end |
Instance Method Details
#process_body(body) ⇒ Object
15 16 17 |
# File 'lib/tamashii/server/response.rb', line 15 def process_body(body) [body.merge(version: Tamashii::VERSION).to_json] end |
#process_header(header, body) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/tamashii/server/response.rb', line 19 def process_header(header, body) header.merge( 'Content-Type' => 'application/json', 'Content-Length' => body.bytesize ) end |