Class: Polar::Resource

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/polar/resource.rb

Class Method Summary collapse

Class Method Details

.handle_list(response, klass = nil) ⇒ Object



8
9
10
11
# File 'lib/polar/resource.rb', line 8

def handle_list(response, klass = nil)
  klass ||= self
  response.fetch("items").map { |attributes| klass.new(attributes) }
end

.handle_none(response) ⇒ Object



18
19
20
# File 'lib/polar/resource.rb', line 18

def handle_none(response)
  response
end

.handle_one(response, klass = nil) ⇒ Object



13
14
15
16
# File 'lib/polar/resource.rb', line 13

def handle_one(response, klass = nil)
  klass ||= self
  klass.new(response)
end