Class: Lydia::Response
- Inherits:
-
Rack::Response
- Object
- Rack::Response
- Lydia::Response
- Defined in:
- lib/lydia/response.rb
Instance Method Summary collapse
- #build(input) ⇒ Object
- #finish(&block) ⇒ Object
-
#initialize ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize ⇒ Response
Returns a new instance of Response.
6 7 8 9 |
# File 'lib/lydia/response.rb', line 6 def initialize(*) super headers['Content-Type'] = 'text/html' if headers['Content-Type'].nil? end |
Instance Method Details
#build(input) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/lydia/response.rb', line 11 def build(input) input_class = input.class.to_s.downcase if %w(string array fixnum hash).include?(input_class) send("build_#{input_class}", input) else build_default(input) end finish end |
#finish(&block) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/lydia/response.rb', line 21 def finish(&block) @block = block if [204, 205, 304].include?(status.to_i) headers.delete('Content-Length') headers.delete('Content-Type') close [status.to_i, header, []] else [status.to_i, header, @body] end end |