Class: ActsAsFerret::RdigAdapter::Indexer

Inherits:
Object
  • Object
show all
Includes:
MonitorMixin
Defined in:
lib/rdig_adapter.rb

Overview

Indexer class to replace RDig’s original indexer

Instance Method Summary collapse

Constructor Details

#initialize(batch_size, model_class, &block) ⇒ Indexer

Returns a new instance of Indexer.



27
28
29
30
31
32
33
34
# File 'lib/rdig_adapter.rb', line 27

def initialize(batch_size, model_class, &block)
  @batch_size = batch_size
  @model_class = model_class
  @documents = []
  @offset = 0
  @block = block
  super()
end

Instance Method Details

#add(doc) ⇒ Object Also known as: <<



36
37
38
39
40
41
# File 'lib/rdig_adapter.rb', line 36

def add(doc)
  synchronize do
    @documents << @model_class.new(doc.uri.to_s, doc)
    process_batch if @documents.size >= @batch_size
  end
end

#closeObject



44
45
46
47
48
# File 'lib/rdig_adapter.rb', line 44

def close
  synchronize do
    process_batch
  end
end