class ThinkingSphinx::RealTime::Populator

Attributes

index[R]

Public Class Methods

new(index) click to toggle source
# File lib/thinking_sphinx/real_time/populator.rb, line 6
def initialize(index)
  @index = index
end
populate(index) click to toggle source
# File lib/thinking_sphinx/real_time/populator.rb, line 2
def self.populate(index)
  new(index).populate
end

Public Instance Methods

populate(&block) click to toggle source
# File lib/thinking_sphinx/real_time/populator.rb, line 10
def populate(&block)
  instrument 'start_populating'

  remove_files

  scope.find_each do |instance|
    transcriber.copy instance
    instrument 'populated', :instance => instance
  end

  controller.rotate
  instrument 'finish_populating'
end

Private Instance Methods

configuration() click to toggle source
# File lib/thinking_sphinx/real_time/populator.rb, line 31
def configuration
  ThinkingSphinx::Configuration.instance
end
instrument(message, options = {}) click to toggle source
# File lib/thinking_sphinx/real_time/populator.rb, line 35
def instrument(message, options = {})
  ActiveSupport::Notifications.instrument(
    "#{message}.thinking_sphinx.real_time", options.merge(:index => index)
  )
end
remove_files() click to toggle source
# File lib/thinking_sphinx/real_time/populator.rb, line 41
def remove_files
  Dir["#{index.path}*"].each { |file| FileUtils.rm file }
end
transcriber() click to toggle source
# File lib/thinking_sphinx/real_time/populator.rb, line 45
def transcriber
  @transcriber ||= ThinkingSphinx::RealTime::Transcriber.new index
end