Module: IronCalc::Batch
- Included in:
- UserModel
- Defined in:
- lib/ironcalc/model.rb
Overview
Prepended rather than included, so batch counts as part of the class
surface.
Instance Method Summary collapse
-
#batch {|model| ... } ⇒ Object
Suspends automatic recalculation, recalculating once when the block exits.
Instance Method Details
#batch {|model| ... } ⇒ Object
Suspends automatic recalculation, recalculating once when the block exits. Nested calls resume only when the outermost block returns, and the recalculation runs even if the block raises — a resumed model that was never recalculated would report stale values indefinitely.
user_model.batch do |m|
rows.each { |row, column, value| m.set_user_input(0, row, column, value) }
end
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/ironcalc/model.rb', line 46 def batch @batch_depth = (@batch_depth || 0) + 1 pause_evaluation if @batch_depth == 1 begin yield self ensure @batch_depth -= 1 if @batch_depth.zero? resume_evaluation evaluate end end end |