Class: CloneKit::Operation
- Inherits:
-
Object
- Object
- CloneKit::Operation
- Extended by:
- Forwardable
- Defined in:
- lib/clone_kit/operation.rb
Defined Under Namespace
Classes: BatchCompleteHandler
Instance Attribute Summary collapse
-
#already_cloned ⇒ Object
readonly
Returns the value of attribute already_cloned.
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
-
#initialize(arguments: {}, id: SecureRandom.uuid, already_cloned: [], strategy: Strategies::Synchronous, event_outlet: CloneKit::EventOutlet.new) ⇒ Operation
constructor
A new instance of Operation.
- #process ⇒ Object
Constructor Details
#initialize(arguments: {}, id: SecureRandom.uuid, already_cloned: [], strategy: Strategies::Synchronous, event_outlet: CloneKit::EventOutlet.new) ⇒ Operation
Returns a new instance of Operation.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/clone_kit/operation.rb', line 16 def initialize(arguments: {}, id: SecureRandom.uuid, already_cloned: [], strategy: Strategies::Synchronous, event_outlet: CloneKit::EventOutlet.new) self.id = id self.arguments = arguments self.already_cloned = already_cloned self.event_outlet = event_outlet self.strategy = strategy.new(self) end |
Instance Attribute Details
#already_cloned ⇒ Object
Returns the value of attribute already_cloned.
12 13 14 |
# File 'lib/clone_kit/operation.rb', line 12 def already_cloned @already_cloned end |
#arguments ⇒ Object
Returns the value of attribute arguments.
12 13 14 |
# File 'lib/clone_kit/operation.rb', line 12 def arguments @arguments end |
#id ⇒ Object
Returns the value of attribute id.
12 13 14 |
# File 'lib/clone_kit/operation.rb', line 12 def id @id end |
Instance Method Details
#process ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/clone_kit/operation.rb', line 28 def process if next_batch.empty? # Done! after_process elsif first_unspecified_model_dependency.present? fail "A clone dependency was added for #{first_unspecified_model_dependency}, but it has no clone specification" else specs = next_batch.map { |model| CloneKit.spec[model] } strategy.clone_next_batch(specs, BatchCompleteHandler) end end |