Class: Ramaze::Response
- Defined in:
- lib/ramaze/response.rb
Class Method Summary collapse
-
.current ⇒ Object
Alias for Current.response.
Instance Method Summary collapse
- #body=(obj) ⇒ Object
-
#build(new_body = nil, new_status = nil, new_header = nil) ⇒ 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.
9 10 11 12 13 |
# File 'lib/ramaze/response.rb', line 9 def initialize(body = [], status = 200, header = {}, &block) modified_header = Ramaze..header.merge(header) header.merge!(modified_header) super end |
Class Method Details
Instance Method Details
#body=(obj) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ramaze/response.rb', line 23 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 = nil, new_status = nil, new_header = nil) ⇒ Object
Build/replace this responses data
16 17 18 19 20 21 |
# File 'lib/ramaze/response.rb', line 16 def build(new_body = nil, new_status = nil, new_header = nil) self.header.merge!(new_header) if new_header self.body = new_body if new_body self.status = new_status if new_status end |