Class: Rack::JSON::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body, options = {}) ⇒ Response

Returns a new instance of Response.



6
7
8
9
10
11
12
13
# File 'lib/rackjson/response.rb', line 6

def initialize(body, options={})
  @status = options[:status] || 200
  @head = options[:head] || false
  @headers = options[:headers] || {}
  parse_body(body)
  head_response if @head
  set_headers
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



4
5
6
# File 'lib/rackjson/response.rb', line 4

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



4
5
6
# File 'lib/rackjson/response.rb', line 4

def headers
  @headers
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/rackjson/response.rb', line 4

def status
  @status
end

Instance Method Details

#to_aObject



15
16
17
# File 'lib/rackjson/response.rb', line 15

def to_a
  [status, headers, [body]]
end