Keeps a stack of batches and helps out when Indexer is asked to batch documents.
If the client does something like
Sunspot.batch do some_code_here which_triggers_some_other_code which_again_calls Sunspot.batch { ... } end
it is the Batcher’s job to keep track of these nestings. The inner will be sent off to be indexed first.
# File lib/sunspot/batcher.rb, line 45 def batching? depth > 0 end
# File lib/sunspot/batcher.rb, line 58 def concat(values) current.concat values end
# File lib/sunspot/batcher.rb, line 27 def current @stack.last or start_new end
# File lib/sunspot/batcher.rb, line 41 def depth @stack.length end
# File lib/sunspot/batcher.rb, line 49 def each(&block) current.each(&block) end
# File lib/sunspot/batcher.rb, line 35 def end_current fail NoCurrentBatchError if @stack.empty? @stack.pop end
# File lib/sunspot/batcher.rb, line 53 def push(value) current << value end
# File lib/sunspot/batcher.rb, line 31 def start_new (@stack << []).last end
# File lib/sunspot/batcher.rb, line 23 def initialize @stack = [] end