Class: Restforce::DB::Associator
- Inherits:
-
Object
- Object
- Restforce::DB::Associator
- Defined in:
- lib/restforce/db/associator.rb
Overview
Restforce::DB::Associator is responsible for determining when one or more associations have been updated to point to a new Salesforce/database record, and propagate the modification to the opposite system when this occurs.
Instance Method Summary collapse
-
#initialize(mapping, runner = Runner.new) ⇒ Associator
constructor
Public: Initialize a new Restforce::DB::Associator.
-
#run ⇒ Object
Public: Run the re-association process, pulling in records from Salesforce and the database to determine the most recently attached association, then propagating the change between systems.
Constructor Details
#initialize(mapping, runner = Runner.new) ⇒ Associator
Public: Initialize a new Restforce::DB::Associator.
mapping - A Restforce::DB::Mapping instance. runner - A Restforce::DB::Runner instance.
15 16 17 18 |
# File 'lib/restforce/db/associator.rb', line 15 def initialize(mapping, runner = Runner.new) @mapping = mapping @runner = runner end |
Instance Method Details
#run ⇒ Object
Public: Run the re-association process, pulling in records from Salesforce and the database to determine the most recently attached association, then propagating the change between systems.
Returns nothing.
25 26 27 28 29 30 31 32 |
# File 'lib/restforce/db/associator.rb', line 25 def run return if belongs_to_associations.empty? @runner.run(@mapping) do |run| run.salesforce_instances.each { |instance| verify_associations(instance) } run.database_instances.each { |instance| verify_associations(instance) } end end |