Module: FsApi::Resource
- Included in:
- Client, Invoice, InvoicesPayment, Product
- Defined in:
- lib/fs_api/resource/resource.rb
Defined Under Namespace
Modules: ClassMethods Classes: Client, Invoice, InvoicesPayment, Product
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#errors ⇒ Object
Returns the value of attribute errors.
Instance Method Summary collapse
-
#from_api=(from_api) ⇒ Object
Bit of a hack to know whether instances came from the api and know they are persisted.
- #initialize(attributes) ⇒ Object
- #persisted? ⇒ Boolean
- #to_json ⇒ Object
- #updateable? ⇒ Boolean
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/fs_api/resource/resource.rb', line 3 def attributes @attributes end |
#errors ⇒ Object
Returns the value of attribute errors.
4 5 6 |
# File 'lib/fs_api/resource/resource.rb', line 4 def errors @errors end |
Instance Method Details
#from_api=(from_api) ⇒ Object
Bit of a hack to know whether instances came from the api and know they are persisted
46 47 48 |
# File 'lib/fs_api/resource/resource.rb', line 46 def from_api=(from_api) @from_api = from_api end |
#initialize(attributes) ⇒ Object
6 7 8 |
# File 'lib/fs_api/resource/resource.rb', line 6 def initialize(attributes) self.attributes = attributes end |
#persisted? ⇒ Boolean
50 51 52 |
# File 'lib/fs_api/resource/resource.rb', line 50 def persisted? @from_api == true end |
#to_json ⇒ Object
36 37 38 |
# File 'lib/fs_api/resource/resource.rb', line 36 def to_json JSON.generate(attributes) end |
#updateable? ⇒ Boolean
40 41 42 |
# File 'lib/fs_api/resource/resource.rb', line 40 def updateable? true end |