Class: Synchronisable::Worker Private
- Inherits:
-
Object
- Object
- Synchronisable::Worker
- Defined in:
- lib/synchronisable/worker.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Responsible for model synchronization.
Class Method Summary collapse
-
.run(model, *args) ⇒ Synchronisable::Context
private
Creates a new instance of worker and initiates model synchronization.
Instance Method Summary collapse
-
#run(data) ⇒ Synchronisable::Context
private
Initiates model synchronization.
Class Method Details
.run(model, data, options) ⇒ Synchronisable::Context .run(model, data) ⇒ Synchronisable::Context .run(model) ⇒ Synchronisable::Context
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new instance of worker and initiates model synchronization.
27 28 29 30 31 32 |
# File 'lib/synchronisable/worker.rb', line 27 def run(model, *args) = args. data = args.first new(model, ).run(data) end |
Instance Method Details
#run(data) ⇒ Synchronisable::Context
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initiates model synchronization.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/synchronisable/worker.rb', line 43 def run(data) sync do |context| error_handler = ErrorHandler.new(@logger, context) context.before = @model.imports_count hashes = DataBuilder.build(@model, @synchronizer, data) hashes.each do |attrs| source = Source.new(@model, @parent, attrs) error_handler.handle(source) do @synchronizer.with_sync_callbacks(source) do sync_record(source) sync_associations(source) set_record_foreign_keys(source) end end end context.after = @model.imports_count context.deleted = 0 end end |