mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Merge pull request #600 from jackrg/master
Fix issue with #insert_before and #insert_after
This commit is contained in:
commit
65e1a7edd8
1 changed files with 4 additions and 2 deletions
|
@ -77,13 +77,15 @@ module Sidekiq
|
|||
end
|
||||
|
||||
def insert_before(oldklass, newklass, *args)
|
||||
new_entry = entries.delete_if { |entry| entry.klass == newklass } || Entry.new(newklass, *args)
|
||||
i = entries.index { |entry| entry.klass == newklass }
|
||||
new_entry = i.nil? ? Entry.new(newklass, *args) : entries.delete_at(i)
|
||||
i = entries.find_index { |entry| entry.klass == oldklass } || 0
|
||||
entries.insert(i, new_entry)
|
||||
end
|
||||
|
||||
def insert_after(oldklass, newklass, *args)
|
||||
new_entry = entries.delete_if { |entry| entry.klass == newklass } || Entry.new(newklass, *args)
|
||||
i = entries.index { |entry| entry.klass == newklass }
|
||||
new_entry = i.nil? ? Entry.new(newklass, *args) : entries.delete_at(i)
|
||||
i = entries.find_index { |entry| entry.klass == oldklass } || entries.count - 1
|
||||
entries.insert(i+1, new_entry)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue