Class: PDC::Http::Result
- Inherits:
-
Object
- Object
- PDC::Http::Result
- Defined in:
- lib/pdc/http/result.rb
Overview
encapsulates http
response
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #data ⇒ Object
- #errors ⇒ Object
-
#initialize(response) ⇒ Result
constructor
A new instance of Result.
- #metadata ⇒ Object
- #pagination ⇒ Object
Constructor Details
#initialize(response) ⇒ Result
Returns a new instance of Result.
6 7 8 9 10 |
# File 'lib/pdc/http/result.rb', line 6 def initialize(response) @body = HashWithIndifferentAccess.new(response.body) @status = response.status @url = response.env.url end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
4 5 6 |
# File 'lib/pdc/http/result.rb', line 4 def body @body end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/pdc/http/result.rb', line 4 def status @status end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'lib/pdc/http/result.rb', line 4 def url @url end |
Instance Method Details
#data ⇒ Object
12 13 14 |
# File 'lib/pdc/http/result.rb', line 12 def data body[:data] end |
#errors ⇒ Object
24 25 26 |
# File 'lib/pdc/http/result.rb', line 24 def errors body[:errors] || [] end |
#metadata ⇒ Object
16 17 18 |
# File 'lib/pdc/http/result.rb', line 16 def body[:metadata] || {} end |
#pagination ⇒ Object
20 21 22 |
# File 'lib/pdc/http/result.rb', line 20 def pagination [PDC::Resource::PAGINATION] || {} end |