Class: Polar::Resource
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Polar::Resource
show all
- Defined in:
- lib/polar/resource.rb
Direct Known Subclasses
Benefit, BenefitGrant, Checkout, Checkout::Custom, Customer, CustomerSession, Discount, LicenseKey, Order, Organization, Product, Refund, Subscription, User
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
|