lib/searchkick.rb in searchkick-0.8.7 vs lib/searchkick.rb in searchkick-0.9.0

- old
+ new

@@ -22,17 +22,15 @@ class MissingIndexError < StandardError; end class UnsupportedVersionError < StandardError; end class InvalidQueryError < Elasticsearch::Transport::Transport::Errors::BadRequest; end class << self - attr_accessor :callbacks attr_accessor :search_method_name attr_accessor :wordnet_path attr_accessor :timeout attr_accessor :models end - self.callbacks = true self.search_method_name = :search self.wordnet_path = "/var/lib/wn_s.pl" self.timeout = 10 self.models = [] @@ -42,27 +40,27 @@ url: ENV["ELASTICSEARCH_URL"], transport_options: {request: {timeout: timeout}} ) end - def self.client=(client) - @client = client + class << self + attr_writer :client end def self.server_version @server_version ||= client.info["version"]["number"] end def self.enable_callbacks - self.callbacks = true + Thread.current[:searchkick_callbacks_enabled] = true end def self.disable_callbacks - self.callbacks = false + Thread.current[:searchkick_callbacks_enabled] = false end def self.callbacks? - callbacks + Thread.current[:searchkick_callbacks_enabled].nil? || Thread.current[:searchkick_callbacks_enabled] end def self.env @env ||= ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development" end