Class: Ramaze::Response
- Defined in:
- lib/ramaze/current/response.rb
Class Method Summary collapse
-
.current ⇒ Object
Alias for Current::response.
Instance Method Summary collapse
- #body=(obj) ⇒ Object
-
#build(new_body = body, status = status, new_header = {}) ⇒ Object
Build/replace this responses data.
-
#initialize(body = [], status = 200, header = {}, &block) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(body = [], status = 200, header = {}, &block) ⇒ Response
Returns a new instance of Response.
11 12 13 14 15 |
# File 'lib/ramaze/current/response.rb', line 11 def initialize(body = [], status = 200, header = {}, &block) header['Content-Type'] ||= Global.content_type header['Accept-Charset'] = Global.accept_charset if Global.accept_charset super end |
Class Method Details
Instance Method Details
#body=(obj) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ramaze/current/response.rb', line 24 def body=(obj) if obj.respond_to?(:stat) @length = obj.stat.size @body = obj elsif obj.respond_to?(:size) @body = [] @length = 0 write(obj) else raise(ArgumentError, "Invalid body: %p" % obj) end end |
#build(new_body = body, status = status, new_header = {}) ⇒ Object
Build/replace this responses data
18 19 20 21 22 |
# File 'lib/ramaze/current/response.rb', line 18 def build(new_body = body, status = status, new_header = {}) self.header.merge!(new_header) self.body, self.status = new_body, status end |