Sha256: 17ce8e36ddac2c49f2c16bdabd06fbc31f02e71bae5513fe8d9281384bc558a4

Contents?: true

Size: 769 Bytes

Versions: 5

Compression:

Stored size: 769 Bytes

Contents

class ThinkingSphinx::Subscribers::PopulatorSubscriber
  def self.attach_to(namespace)
    subscriber = new

    subscriber.public_methods(false).each do |event|
      next if event == :call

      ActiveSupport::Notifications.subscribe(
        "#{event}.#{namespace}", subscriber
      )
    end
  end

  def call(message, *args)
    send message.split('.').first,
      ActiveSupport::Notifications::Event.new(message, *args)
  end

  def start_populating(event)
    puts "Generating index files for #{event.payload[:index].name}"
  end

  def populated(event)
    print '.' * event.payload[:instances].length
  end

  def finish_populating(event)
    print "\n"
  end
end

ThinkingSphinx::Subscribers::PopulatorSubscriber.attach_to(
  'thinking_sphinx.real_time'
)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
thinking-sphinx-3.4.2 lib/thinking_sphinx/subscribers/populator_subscriber.rb
thinking-sphinx-3.4.1 lib/thinking_sphinx/subscribers/populator_subscriber.rb
thinking-sphinx-3.4.0 lib/thinking_sphinx/subscribers/populator_subscriber.rb
thinking-sphinx-3.3.0 lib/thinking_sphinx/subscribers/populator_subscriber.rb
thinking-sphinx-3.2.0 lib/thinking_sphinx/subscribers/populator_subscriber.rb