Class: Gecko::Record::Base
- Inherits:
-
Object
- Object
- Gecko::Record::Base
- Includes:
- Helpers::AssociationHelper, Helpers::InspectionHelper, Helpers::SerializationHelper, Helpers::ValidationHelper, LiquidCompatibility
- Defined in:
- lib/gecko/record/base.rb
Direct Known Subclasses
Account, Address, Company, Contact, Currency, Fulfillment, FulfillmentLineItem, Image, Invoice, InvoiceLineItem, Location, Note, Order, OrderLineItem, PaymentMethod, PaymentTerm, Product, PurchaseOrder, PurchaseOrderLineItem, TaxType, User, Variant, Webhook
Class Method Summary collapse
-
.demodulized_name ⇒ String
private
Return the demodulized class name.
Instance Method Summary collapse
-
#initialize(client, attributes = {}) ⇒ undefined
constructor
private
Overrides the default Virtus functionality to store: - The Gecko::Client used to create the object - a raw copy of the attributes for the association helpers to read from.
-
#persisted? ⇒ Boolean
Whether the record has been persisted.
-
#save(opts = {}) ⇒ Gecko::Record::Base
Save a record.
Methods included from LiquidCompatibility
Methods included from Helpers::ValidationHelper
Methods included from Helpers::SerializationHelper
#_serialize, #as_json, #root, #serializable_hash, #serialize_attribute, #writeable?
Methods included from Helpers::InspectionHelper
Methods included from Helpers::AssociationHelper
Constructor Details
#initialize(client, attributes = {}) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Overrides the default Virtus functionality to store:
-
The Gecko::Client used to create the object
-
a raw copy of the attributes for the association helpers to read from
29 30 31 32 |
# File 'lib/gecko/record/base.rb', line 29 def initialize(client, attributes = {}) super(attributes) @client = client end |
Class Method Details
.demodulized_name ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the demodulized class name
66 67 68 |
# File 'lib/gecko/record/base.rb', line 66 def self.demodulized_name name.split('::').last end |
Instance Method Details
#persisted? ⇒ Boolean
Whether the record has been persisted
42 43 44 |
# File 'lib/gecko/record/base.rb', line 42 def persisted? !!id end |
#save(opts = {}) ⇒ Gecko::Record::Base
Save a record
54 55 56 |
# File 'lib/gecko/record/base.rb', line 54 def save(opts = {}) @client.adapter_for(self.class.demodulized_name).save(self, opts) end |