Skip to content

Commit

Permalink
DJ pre-2.0 can still be supported.
Browse files Browse the repository at this point in the history
  • Loading branch information
pat committed Apr 24, 2013
1 parent 214cebb commit 056902d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/thinking_sphinx/deltas/delayed_delta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@ def self.enqueue_unless_duplicates(object)
:locked_at => nil
).count > 0

Delayed::Job.enqueue object, :priority => priority
Delayed::Job.enqueue object, priority_option
end

def self.priority_option
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
end

def self.priority
Expand Down Expand Up @@ -65,7 +74,7 @@ def index(model, instance = nil)
Delayed::Job.enqueue(
ThinkingSphinx::Deltas::DelayedDelta::FlagAsDeletedJob.new(
model.core_index_names, instance.sphinx_document_id
), :priority => self.class.priority
), self.class.priority_option
) if instance

true
Expand All @@ -91,7 +100,7 @@ def delete(index, instance)
Delayed::Job.enqueue(
ThinkingSphinx::Deltas::DelayedDelta::FlagAsDeletedJob.new(
index.name, index.document_id_for_key(instance.id)
), :priority => self.class.priority
), self.class.priority_option
)
end

Expand Down

0 comments on commit 056902d

Please sign in to comment.