Class: RestChain::RestResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/rest_chain/rest_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, headers, body) ⇒ RestResponse

Returns a new instance of RestResponse.



5
6
7
8
9
# File 'lib/rest_chain/rest_response.rb', line 5

def initialize(status, headers, body)
  @status  = status
  @headers = headers
  @body    = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



10
11
12
# File 'lib/rest_chain/rest_response.rb', line 10

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



10
11
12
# File 'lib/rest_chain/rest_response.rb', line 10

def headers
  @headers
end

#statusObject (readonly)

Returns the value of attribute status.



10
11
12
# File 'lib/rest_chain/rest_response.rb', line 10

def status
  @status
end

Instance Method Details

#json(options = {}) ⇒ Object



16
17
18
# File 'lib/rest_chain/rest_response.rb', line 16

def json(options={})
  JSON.parse(body, options)
end

#success?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/rest_chain/rest_response.rb', line 12

def success?
  (200..299).include?(@status)
end