Browse files

Fixed compatibility issue #21 with DelayedJob 2.0.7 (needed with Rail…

…s 2.3.x)
  • Loading branch information...
1 parent a94bc47 commit 6b286ef5278c6f7128b7e0e5e3177de7220a74d8 @ledermann ledermann committed Mar 2, 2012
Showing with 16 additions and 2 deletions.
  1. +8 −1 lib/thinking_sphinx/deltas/delayed_delta.rb
  2. +8 −1 lib/thinking_sphinx/deltas/delayed_delta/job.rb
View
9 lib/thinking_sphinx/deltas/delayed_delta.rb
@@ -41,11 +41,18 @@ def index(model, instance = nil)
ThinkingSphinx::Configuration.instance.delayed_job_priority
)
+ options = if Gem.loaded_specs['delayed_job'].version.to_s.match(/^2\.0\./)
+ # Fallback for compatibility with old release 2.0.x of DJ
+ ThinkingSphinx::Configuration.instance.delayed_job_priority
+ else
+ { :priority => ThinkingSphinx::Configuration.instance.delayed_job_priority }
+ end
+
Delayed::Job.enqueue(
ThinkingSphinx::Deltas::FlagAsDeletedJob.new(
model.core_index_names, instance.sphinx_document_id
),
- :priority => ThinkingSphinx::Configuration.instance.delayed_job_priority
+ options
) if instance
true
View
9 lib/thinking_sphinx/deltas/delayed_delta/job.rb
@@ -27,7 +27,14 @@ class ThinkingSphinx::Deltas::Job < Delayed::Backend::ActiveRecord::Job
# @param [Integer] priority (0)
#
def self.enqueue(object, priority = 0)
- ::Delayed::Job.enqueue(object, :priority => priority) unless duplicates_exist(object)
+ options = if Gem.loaded_specs['delayed_job'].version.to_s.match(/^2\.0\./)
+ # Fallback for compatibility with old release 2.0.x of DJ
+ priority
+ else
+ { :priority => priority }
+ end
+
+ ::Delayed::Job.enqueue(object, options) unless duplicates_exist(object)
end
# Remove all Thinking Sphinx/Delayed Delta jobs from the queue. If the

0 comments on commit 6b286ef

Please sign in to comment.