Sha256: 28bd68e8c778628140c946054eb06fd81daf0ff827a8789599760893d44600aa

Contents?: true

Size: 734 Bytes

Versions: 7

Compression:

Stored size: 734 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 '.'
  end

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
thinking-sphinx-3.1.4 lib/thinking_sphinx/subscribers/populator_subscriber.rb
thinking-sphinx-3.1.3 lib/thinking_sphinx/subscribers/populator_subscriber.rb
thinking-sphinx-3.1.2 lib/thinking_sphinx/subscribers/populator_subscriber.rb
thinking-sphinx-3.1.1 lib/thinking_sphinx/subscribers/populator_subscriber.rb
thinking-sphinx-3.1.0 lib/thinking_sphinx/subscribers/populator_subscriber.rb
thinking-sphinx-3.0.6 lib/thinking_sphinx/subscribers/populator_subscriber.rb
thinking-sphinx-3.0.5 lib/thinking_sphinx/subscribers/populator_subscriber.rb