Created
June 25, 2020 03:24
-
-
Save jambun/0d66ee6f37344d4e7f6453e39f194daf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
unless RealtimeIndexing.respond_to?(:disable) | |
RealtimeIndexing.class_eval do | |
def self.disable(&block) | |
begin | |
Thread.current[:realtime_indexing_disabled] = true | |
block.call | |
ensure | |
Thread.current[:realtime_indexing_disabled] = false | |
end | |
end | |
def self.record_update(target, uri) | |
unless Thread.current[:realtime_indexing_disabled] | |
longpolling.record_update(:record => target, :uri => uri) | |
end | |
end | |
def self.record_delete(uri) | |
unless Thread.current[:realtime_indexing_disabled] | |
longpolling.record_update(:record => :deleted, :uri => uri) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment