Class: Idsimple::Rack::Api::Result
- Inherits:
-
Object
- Object
- Idsimple::Rack::Api::Result
- Defined in:
- lib/idsimple/rack/api.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #body ⇒ Object
- #fail? ⇒ Boolean
- #full_error_message ⇒ Object
-
#initialize(response) ⇒ Result
constructor
A new instance of Result.
- #status ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Result
Returns a new instance of Result.
48 49 50 |
# File 'lib/idsimple/rack/api.rb', line 48 def initialize(response) @response = response end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
46 47 48 |
# File 'lib/idsimple/rack/api.rb', line 46 def response @response end |
Instance Method Details
#body ⇒ Object
64 65 66 |
# File 'lib/idsimple/rack/api.rb', line 64 def body @body ||= JSON.parse(response.body) if response.body end |
#fail? ⇒ Boolean
56 57 58 |
# File 'lib/idsimple/rack/api.rb', line 56 def fail? !success? end |
#full_error_message ⇒ Object
68 69 70 |
# File 'lib/idsimple/rack/api.rb', line 68 def "#{body["errors"].join(". ")}." if body && body["errors"] end |
#status ⇒ Object
60 61 62 |
# File 'lib/idsimple/rack/api.rb', line 60 def status response.code end |
#success? ⇒ Boolean
52 53 54 |
# File 'lib/idsimple/rack/api.rb', line 52 def success? response.kind_of?(Net::HTTPSuccess) end |