Class: Clever::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(faraday_response) ⇒ Response

Returns a new instance of Response.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/clever/response.rb', line 9

def initialize(faraday_response)
  @status   = faraday_response.status
  @raw_body = faraday_response.body

  return unless faraday_response.body

  @body     = faraday_response.body['data']
  @links    = faraday_response.body['links']

  uri(:self)
  uri(:next)
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



7
8
9
# File 'lib/clever/response.rb', line 7

def body
  @body
end

Returns the value of attribute links.



5
6
7
# File 'lib/clever/response.rb', line 5

def links
  @links
end

#next_uriObject (readonly)

Returns the value of attribute next_uri.



5
6
7
# File 'lib/clever/response.rb', line 5

def next_uri
  @next_uri
end

#raw_bodyObject (readonly)

Returns the value of attribute raw_body.



5
6
7
# File 'lib/clever/response.rb', line 5

def raw_body
  @raw_body
end

#self_uriObject (readonly)

Returns the value of attribute self_uri.



5
6
7
# File 'lib/clever/response.rb', line 5

def self_uri
  @self_uri
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/clever/response.rb', line 5

def status
  @status
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


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

def success?
  @status == 200
end