Class: Spyke::Result
- Inherits:
-
Object
- Object
- Spyke::Result
- Defined in:
- lib/spyke/result.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Class Method Summary collapse
Instance Method Summary collapse
- #data ⇒ Object
- #errors ⇒ Object
-
#initialize(body) ⇒ Result
constructor
A new instance of Result.
- #metadata ⇒ Object
Constructor Details
#initialize(body) ⇒ Result
Returns a new instance of Result.
9 10 11 |
# File 'lib/spyke/result.rb', line 9 def initialize(body) @body = HashWithIndifferentAccess.new(body) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/spyke/result.rb', line 3 def body @body end |
Class Method Details
.new_from_response(response) ⇒ Object
5 6 7 |
# File 'lib/spyke/result.rb', line 5 def self.new_from_response(response) new(response.body) end |
Instance Method Details
#data ⇒ Object
13 14 15 |
# File 'lib/spyke/result.rb', line 13 def data body[:data] end |
#errors ⇒ Object
21 22 23 |
# File 'lib/spyke/result.rb', line 21 def errors body[:errors] || [] end |
#metadata ⇒ Object
17 18 19 |
# File 'lib/spyke/result.rb', line 17 def body[:metadata] || {} end |