Class: Syncify::Sync

Inherits:
ActiveInteraction::Base
  • Object
show all
Defined in:
lib/syncify/sync.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#has_and_belongs_to_many_associationsObject

Returns the value of attribute has_and_belongs_to_many_associations.



14
15
16
# File 'lib/syncify/sync.rb', line 14

def has_and_belongs_to_many_associations
  @has_and_belongs_to_many_associations
end

#identified_recordsObject

Returns the value of attribute identified_records.



13
14
15
# File 'lib/syncify/sync.rb', line 13

def identified_records
  @identified_records
end

Instance Method Details

#executeObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/syncify/sync.rb', line 18

def execute
  puts 'Identifying records to sync...'
  @identified_records = Set[]
  @has_and_belongs_to_many_associations = {}

  remote do
    associations = normalized_associations(association)
    initial_query.each do |root_record|
      identify_associated_records(root_record, associations)
    end
  end

  puts "\nIdentified #{identified_records.size} records to sync."

  callback.call(identified_records) if callback.present?

  sync_records
end