Class: RackStep::Response

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

Instance Method Summary collapse

Instance Method Details

#body=(value) ⇒ Object

The original body= method of Rack::Response expects an array. In RackStep the user may set it as a String and we will convert it to array if necessary.



11
12
13
14
15
16
17
18
# File 'lib/response.rb', line 11

def body=(value)
  if value.is_a?(String)
    # Convert it to an array.
    value = [value]
  end

  super(value)
end

#content_typeObject

Just a helper to get the content type from the response header.



21
22
23
# File 'lib/response.rb', line 21

def content_type
  header['Content-Type']
end

#content_type=(value) ⇒ Object

Just a helper to set the content type on the response header.



26
27
28
# File 'lib/response.rb', line 26

def content_type=(value)
  header['Content-Type'] = value
end

#redirect_to(address) ⇒ Object

A helper for redirecting to another adddress. Will send back a 302 status code.



32
33
34
35
# File 'lib/response.rb', line 32

def redirect_to(address)
  @status = 302
  header['Location'] = address
end