Class: Restforce::DB::Instances::Salesforce
- Defined in:
- lib/restforce/db/instances/salesforce.rb
Overview
Restforce::DB::Instances::Salesforce serves as a wrapper for Salesforce objects, exposing a common API to reconcile record attributes with ActiveRecord instances.
Constant Summary collapse
- INTERNAL_ATTRIBUTES =
%w( Id SynchronizationId__c SystemModstamp LastModifiedById ).freeze
Instance Attribute Summary
Attributes inherited from Base
#mapping, #record, #record_type
Instance Method Summary collapse
-
#id ⇒ Object
Public: Get a common identifier for this record.
-
#last_update ⇒ Object
Public: Get the time of the last update to this record.
-
#synced? ⇒ Boolean
Public: Has this record been synced with Salesforce?.
-
#update!(attributes) ⇒ Object
Public: Update the instance with the passed attributes.
-
#updated_internally? ⇒ Boolean
Public: Was this record most recently updated by Restforce::DB’s workflow?.
Methods inherited from Base
#after_sync, #attributes, #initialize
Constructor Details
This class inherits a constructor from Restforce::DB::Instances::Base
Instance Method Details
#id ⇒ Object
Public: Get a common identifier for this record.
Returns a String.
22 23 24 |
# File 'lib/restforce/db/instances/salesforce.rb', line 22 def id @record.Id end |
#last_update ⇒ Object
Public: Get the time of the last update to this record.
Returns a Time-compatible object.
39 40 41 |
# File 'lib/restforce/db/instances/salesforce.rb', line 39 def last_update Time.parse(@record.SystemModstamp) end |
#synced? ⇒ Boolean
Public: Has this record been synced with Salesforce?
Returns a Boolean.
46 47 48 |
# File 'lib/restforce/db/instances/salesforce.rb', line 46 def synced? @mapping.database_model.exists?(@mapping.lookup_column => id) end |
#update!(attributes) ⇒ Object
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.
32 33 34 |
# File 'lib/restforce/db/instances/salesforce.rb', line 32 def update!(attributes) super FieldProcessor.new.process(@record_type, attributes, :update) end |