Class: Restforce::DB::Cleaner

Inherits:
Object
  • Object
show all
Defined in:
lib/restforce/db/cleaner.rb

Overview

Restforce::DB::Cleaner is responsible for culling the matching database records when a Salesforce record no longer meets the sync conditions.

Instance Method Summary collapse

Constructor Details

#initialize(mapping, runner = Runner.new) ⇒ Cleaner

Public: Initialize a Restforce::DB::Cleaner.

mapping - A Restforce::DB::Mapping. runner - A Restforce::DB::Runner.



13
14
15
16
17
# File 'lib/restforce/db/cleaner.rb', line 13

def initialize(mapping, runner = Runner.new)
  @mapping = mapping
  @strategy = mapping.strategy
  @runner = runner
end

Instance Method Details

#runObject

Public: Run the database culling loop for this mapping.

Returns nothing.



22
23
24
25
# File 'lib/restforce/db/cleaner.rb', line 22

def run
  return if @mapping.conditions.empty? || @strategy.passive?
  @mapping.database_record_type.destroy_all(invalid_salesforce_ids)
end