Skip to content
Browse files

update to backgrounded 2.x API

  • Loading branch information...
1 parent 0d04fa1 commit 61ccb05d50ec1090f32c570b80482e56ab573639 @wireframe wireframe committed Sep 26, 2012
Showing with 4 additions and 9 deletions.
  1. +1 −1 elastic_searchable.gemspec
  2. +3 −8 lib/elastic_searchable/active_record_extensions.rb
View
2 elastic_searchable.gemspec
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency(%q<activerecord>, [">= 3.0.5"])
s.add_runtime_dependency(%q<httparty>, [">= 0.6.0"])
- s.add_runtime_dependency(%q<backgrounded>, [">= 0.7.0"])
+ s.add_runtime_dependency(%q<backgrounded>, [">= 2.0.0"])
s.add_runtime_dependency(%q<multi_json>, [">= 1.0.0"])
s.add_development_dependency(%q<rake>, ["0.9.2.2"])
s.add_development_dependency(%q<sqlite3>, ["1.3.5"])
View
11 lib/elastic_searchable/active_record_extensions.rb
@@ -37,13 +37,8 @@ def elastic_searchable(options = {})
ActiveSupport::Deprecation.warn ":index has been deprecated. Use ElasticSearchable.index_name instead.", caller
end
- backgrounded :update_index_on_create => ElasticSearchable.backgrounded_options, :update_index_on_update => ElasticSearchable.backgrounded_options
- class << self
- backgrounded :delete_id_from_index => ElasticSearchable.backgrounded_options
- end
-
- after_commit :update_index_on_create_backgrounded, :if => :should_index?, :on => :create
- after_commit :update_index_on_update_backgrounded, :if => :should_index?, :on => :update
+ after_commit_backgrounded :update_index_on_create, :if => :should_index?, :on => :create, :backgrounded => ElasticSearchable.backgrounded_options
+ after_commit_backgrounded :update_index_on_update, :if => :should_index?, :on => :update, :backgrounded => ElasticSearchable.backgrounded_options
after_commit :delete_from_index, :unless => :elasticsearch_offline?, :on => :destroy
end
end
@@ -245,7 +240,7 @@ def percolate(percolator_query = nil)
private
def delete_from_index
- self.class.delete_id_from_index_backgrounded self.id
+ self.class.backgrounded(ElasticSearchable.backgrounded_options).delete_id_from_index self.id
end
def update_index_on_create
reindex :create

0 comments on commit 61ccb05

Please sign in to comment.
Something went wrong with that request. Please try again.