-
-
Save kivanio/9943651 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SidekiqIndexing | |
module SearchableOverride | |
extend ActiveSupport::Concern | |
module InstanceOverrides | |
def solr_index | |
SunspotIndexer.perform_async(self.class.to_s, self.id) | |
end | |
end | |
module ClassMethods | |
def searchable(*args, &blk) | |
super | |
include InstanceOverrides | |
end | |
end | |
end | |
class Railtie < ::Rails::Railtie | |
initializer 'sidekiq_indexing.init' do | |
ActiveSupport.on_load(:active_record) do | |
include(SidekiqIndexing::SearchableOverride) | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SunspotIndexer | |
include Sidekiq::Worker | |
def perform(klass_name, id) | |
Sunspot.index(klass_name.constantize.find(id)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment