Class: Ramaze::Response

Inherits:
Rack::Response
  • Object
show all
Defined in:
lib/ramaze/response.rb

Class Method Summary collapse

Instance Method Summary collapse

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.options.header.merge(header)
  header.merge!(modified_header)
  super
end

Class Method Details

.currentObject

Alias for Current.response



7
# File 'lib/ramaze/response.rb', line 7

def self.current; Current.response; end

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