class Restforce::DB::Instances::Base
Restforce::DB::Instances::Base
defines common behavior for the other models defined in the Restforce::DB::Instances
namespace.
Attributes
Public Class Methods
Public: Initialize a new Restforce::DB::Instances::Base
instance.
record_type
- A String or Class describing the record's type. record - The Salesforce
or database record to manage. mapping - An instance of Restforce::DB::Mapping
.
# File lib/restforce/db/instances/base.rb, line 18 def initialize(record_type, record, mapping = nil) @record_type = record_type @record = record @mapping = mapping end
Public Instance Methods
Public: A hook which is performed after records are synchronized. Override this method in subclasses to inject generic behaviors into the record synchronization flow.
Returns self.
# File lib/restforce/db/instances/base.rb, line 57 def after_sync self end
Public: Get a Hash mapping the configured attributes names to their values for this instance.
Returns a Hash.
# File lib/restforce/db/instances/base.rb, line 41 def attributes @mapping.attributes(@record_type, record) end
Public: Has this record been synced with Salesforce
?
Returns a Boolean.
# File lib/restforce/db/instances/base.rb, line 48 def synced? true end
Public: Update the instance with the passed attributes.
attributes - A Hash mapping attribute names to values.
Returns self. Raises if the update fails for any reason.
# File lib/restforce/db/instances/base.rb, line 30 def update!(attributes) return self if attributes.empty? record.update!(attributes) after_sync end