Class: Synchronisable::Controller Private
- Includes:
- Helper::Logging
- Defined in:
- lib/synchronisable/controller.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.
Constant Summary collapse
- VALID_OPTIONS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%i(includes parent)
Instance Attribute Summary collapse
- #logger ⇒ Object readonly private
Class Method Summary collapse
-
.call(model, *args) ⇒ Synchronisable::Context
private
Creates a new instance of controller and initiates model synchronization.
Instance Method Summary collapse
-
#call(data) ⇒ Synchronisable::Context
private
Initiates model synchronization.
Instance Attribute Details
#logger ⇒ Object (readonly)
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.
19 20 21 |
# File 'lib/synchronisable/controller.rb', line 19 def logger @logger end |
Class Method Details
.call(model, data, options) ⇒ Synchronisable::Context .call(model, data) ⇒ Synchronisable::Context .call(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 controller and initiates model synchronization.
36 37 38 39 |
# File 'lib/synchronisable/controller.rb', line 36 def call(model, *args) data, = *extract_args(args) new(model, ).call(data) end |
Instance Method Details
#call(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.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/synchronisable/controller.rb', line 78 def call(data) sync do |context| error_handler = ErrorHandler.new(logger, context) source = Source.new(@model, @parent, @includes) context.before = @model.imports_count hashes = @input.parse(data) hashes.each do |attrs| error_handler.handle(source) do source.prepare(data, attrs) record_worker = Worker::Record.new(@synchronizer, source) associations_worker = Worker::Associations.new(@synchronizer, source) @synchronizer.with_sync_callbacks(source) do associations_worker.sync_parent_associations record_worker.sync_record associations_worker.sync_child_associations end end end context.after = @model.imports_count context.deleted = 0 end end |