Skip to content

Instantly share code, notes, and snippets.

@jambun
Created June 25, 2020 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jambun/0d66ee6f37344d4e7f6453e39f194daf to your computer and use it in GitHub Desktop.
Save jambun/0d66ee6f37344d4e7f6453e39f194daf to your computer and use it in GitHub Desktop.
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