Class: Spyke::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/spyke/result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#bodyObject (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

#dataObject



13
14
15
# File 'lib/spyke/result.rb', line 13

def data
  body[:data]
end

#errorsObject



21
22
23
# File 'lib/spyke/result.rb', line 21

def errors
  body[:errors] || []
end

#metadataObject



17
18
19
# File 'lib/spyke/result.rb', line 17

def 
  body[:metadata] || {}
end