Sha256: 09c1956126b2ca17c2fd8aa192601045b8972669a67aa48942d4830fd8b6a377
Contents?: true
Size: 1.01 KB
Versions: 11
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true 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 error(event) error = event.payload[:error].inner_exception instance = event.payload[:error].instance puts <<-MESSAGE Error transcribing #{instance.class} #{instance.id}: #{error.message} MESSAGE 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 private delegate :output, :to => ThinkingSphinx delegate :puts, :print, :to => :output end
Version data entries
11 entries across 11 versions & 1 rubygems