Class: Cartomodel::Synchronizer
- Inherits:
-
Object
- Object
- Cartomodel::Synchronizer
- Defined in:
- lib/cartomodel/synchronizer.rb
Class Method Summary collapse
Class Method Details
.get_failed_synced_instances ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/cartomodel/synchronizer.rb', line 22 def self.get_failed_synced_instances result = [] ActiveRecord::Base.descendants.each do |active_record_descendant| next if active_record_descendant.included_modules.exclude? Cartomodel::Model::Synchronizable or !ActiveRecord::Base.connection.column_exists? active_record_descendant.table_name, :sync_state result.concat active_record_descendant.where(sync_state: Cartomodel::Model::Synchronizable::STATE_FAILED) end result end |
.sync_all ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/cartomodel/synchronizer.rb', line 3 def self.sync_all self.get_failed_synced_instances.each do |object| object.class.skip_callback(:create, :before, :create_on_cartodb) object.class.skip_callback(:update, :before, :update_on_cartodb) begin if object.cartodb_id then object.update_on_cartodb else object.create_on_cartodb end object.save ensure object.class.set_callback(:create, :before, :create_on_cartodb) object.class.set_callback(:update, :before, :update_on_cartodb) end end end |