class Gecko::Record::Base

Public Class Methods

demodulized_name() click to toggle source

Return the demodulized class name

@example

Gecko::Record::Product.demodulized_name #=> "Product"

@return [String]

@api private

# File lib/gecko/record/base.rb, line 66
def self.demodulized_name
  name.split('::').last
end
new(client, attributes = {}) click to toggle source

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

@return [undefined]

@api private

Calls superclass method
# File lib/gecko/record/base.rb, line 29
def initialize(client, attributes = {})
  super(attributes)
  @client = client
end

Public Instance Methods

persisted?() click to toggle source

Whether the record has been persisted

@example

variant.persisted? #=> true

@return <Boolean>

@api public

# File lib/gecko/record/base.rb, line 42
def persisted?
  !!id
end
save(opts = {}) click to toggle source

Save a record

@param [Hash] opts the options to save the record with @option opts [Hash] :idempotency_key A unique identifier for this action

@return <Gecko::Record::Base>

@api public

# File lib/gecko/record/base.rb, line 54
def save(opts = {})
  @client.adapter_for(self.class.demodulized_name).save(self, opts)
end