Method: Cequel::Metal::BatchManager#batch
- Defined in:
- lib/cequel/metal/batch_manager.rb
#batch(options = {}) { ... } ⇒ Object
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.
Note:
If this method is created while already in a batch of the same type (logged or unlogged), this method is a no-op.
Execute write operations in a batch. Any inserts, updates, and deletes inside this method’s block will be executed inside a CQL BATCH operation.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cequel/metal/batch_manager.rb', line 39 def batch( = {}) new_batch = Batch.new(keyspace, ) if current_batch if current_batch.unlogged? && new_batch.logged? fail ArgumentError, "Already in an unlogged batch; can't start a logged batch." end return yield(current_batch) end begin self.current_batch = new_batch yield(new_batch).tap { new_batch.apply } ensure self.current_batch = nil end end |