Module: XeroKiwi::Accounting::Resource::ClassMethods
- Defined in:
- lib/xero_kiwi/accounting/resource.rb
Instance Method Summary collapse
- #attribute(name, xero:, type: :string, of: nil, reference: false, hydrate: nil) ⇒ Object
- #attributes ⇒ Object
- #from_response(payload) ⇒ Object
- #identity(*attrs) ⇒ Object
- #identity_attributes ⇒ Object
- #payload_key(key = nil) ⇒ Object
Instance Method Details
#attribute(name, xero:, type: :string, of: nil, reference: false, hydrate: nil) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/xero_kiwi/accounting/resource.rb', line 41 def attribute(name, xero:, type: :string, of: nil, reference: false, hydrate: nil) attributes[name] = { xero: xero, type: type, of: of, reference: reference, hydrate: hydrate } attr_reader name end |
#attributes ⇒ Object
53 54 55 |
# File 'lib/xero_kiwi/accounting/resource.rb', line 53 def attributes @_attributes ||= {} end |
#from_response(payload) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/xero_kiwi/accounting/resource.rb', line 65 def from_response(payload) return [] if payload.nil? items = payload[payload_key] return [] if items.nil? items.map { |attrs| new(attrs) } end |
#identity(*attrs) ⇒ Object
57 58 59 |
# File 'lib/xero_kiwi/accounting/resource.rb', line 57 def identity(*attrs) @identity_attributes = attrs.freeze end |
#identity_attributes ⇒ Object
61 62 63 |
# File 'lib/xero_kiwi/accounting/resource.rb', line 61 def identity_attributes @identity_attributes end |
#payload_key(key = nil) ⇒ Object
35 36 37 38 39 |
# File 'lib/xero_kiwi/accounting/resource.rb', line 35 def payload_key(key = nil) return @payload_key if key.nil? @payload_key = key end |