Class: Keymaker::Response
- Inherits:
-
Object
- Object
- Keymaker::Response
- Defined in:
- lib/keymaker/response.rb
Instance Attribute Summary collapse
-
#faraday_response ⇒ Object
Returns the value of attribute faraday_response.
-
#request ⇒ Object
Returns the value of attribute request.
-
#service ⇒ Object
Returns the value of attribute service.
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(service, faraday_response) ⇒ Response
constructor
A new instance of Response.
- #neo4j_id ⇒ Object
- #on_error ⇒ Object
- #on_success ⇒ Object
- #status ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(service, faraday_response) ⇒ Response
Returns a new instance of Response.
9 10 11 12 |
# File 'lib/keymaker/response.rb', line 9 def initialize(service, faraday_response) self.service = service self.faraday_response = faraday_response end |
Instance Attribute Details
#faraday_response ⇒ Object
Returns the value of attribute faraday_response.
7 8 9 |
# File 'lib/keymaker/response.rb', line 7 def faraday_response @faraday_response end |
#request ⇒ Object
Returns the value of attribute request.
5 6 7 |
# File 'lib/keymaker/response.rb', line 5 def request @request end |
#service ⇒ Object
Returns the value of attribute service.
6 7 8 |
# File 'lib/keymaker/response.rb', line 6 def service @service end |
Instance Method Details
#body ⇒ Object
14 15 16 |
# File 'lib/keymaker/response.rb', line 14 def body faraday_response.body || {} end |
#neo4j_id ⇒ Object
22 23 24 |
# File 'lib/keymaker/response.rb', line 22 def neo4j_id body["self"] && body["self"][/\d+$/].to_i end |
#on_error ⇒ Object
37 38 39 40 41 42 |
# File 'lib/keymaker/response.rb', line 37 def on_error unless success? yield self end self end |
#on_success ⇒ Object
26 27 28 29 30 31 |
# File 'lib/keymaker/response.rb', line 26 def on_success if success? yield self end self end |
#status ⇒ Object
18 19 20 |
# File 'lib/keymaker/response.rb', line 18 def status faraday_response.status end |
#success? ⇒ Boolean
33 34 35 |
# File 'lib/keymaker/response.rb', line 33 def success? (200..299).include?(status) end |