Class: Feathr::Api::FeathrObject
- Inherits:
-
FeathrEndpoint
- Object
- FeathrEndpoint
- Feathr::Api::FeathrObject
- Defined in:
- lib/feathr/api/feathr_object.rb
Direct Known Subclasses
Account, Cashout, Contractor, Income, IncomeRequest, Invoice, Manager, Membership, MembershipRequest, Platform, Rebate, Receiveable, User
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#id ⇒ Object
Returns the value of attribute id.
Attributes inherited from FeathrEndpoint
Class Method Summary collapse
Instance Method Summary collapse
- #as_json ⇒ Object
- #full_path ⇒ Object
-
#initialize(data, id) ⇒ FeathrObject
constructor
A new instance of FeathrObject.
- #path ⇒ Object
Methods inherited from FeathrEndpoint
api_path, define_all, define_create, define_destroy, define_find, define_update, feathr_endpoints, feathr_object
Constructor Details
#initialize(data, id) ⇒ FeathrObject
Returns a new instance of FeathrObject.
9 10 11 12 13 14 |
# File 'lib/feathr/api/feathr_object.rb', line 9 def initialize(data, id) @data = data @id = id super() end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
5 6 7 |
# File 'lib/feathr/api/feathr_object.rb', line 5 def data @data end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/feathr/api/feathr_object.rb', line 5 def id @id end |
Class Method Details
.nested(*resources) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/feathr/api/feathr_object.rb', line 28 def self.nested(*resources) resources.each do |resource| define_method(resource) do ivar = "@#{ resource }" klass_name = resource.to_s.split('_').collect(&:capitalize).join klass = Object.const_get("Feathr::Api::#{ klass_name }") instance_variable_get(ivar) || instance_variable_set(ivar, klass.new(prepended_path: path)) end end end |
Instance Method Details
#as_json ⇒ Object
24 25 26 |
# File 'lib/feathr/api/feathr_object.rb', line 24 def as_json data.to_h end |
#full_path ⇒ Object
20 21 22 |
# File 'lib/feathr/api/feathr_object.rb', line 20 def full_path url = [client.config.base_url, path].join('/') + "/" end |
#path ⇒ Object
16 17 18 |
# File 'lib/feathr/api/feathr_object.rb', line 16 def path [api_path, id].join('') end |