mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Change behavior to move an existing middleware to the requested position rather than ignoring existing middle wares.
This commit is contained in:
parent
71931fc0e1
commit
9d9f9732a2
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 { |entry| entry.klass == newklass } || Entry.new(newklass, *args)
|
||||
i = entries.find_index { |entry| entry.klass == oldklass } || 0
|
||||
entries.insert(i, Entry.new(newklass, *args)) unless exists?(newklass)
|
||||
entries.insert(i, new_entry)
|
||||
end
|
||||
|
||||
def insert_after(oldklass, newklass, *args)
|
||||
new_entry = entries.delete { |entry| entry.klass == newklass } || Entry.new(newklass, *args)
|
||||
i = entries.find_index { |entry| entry.klass == oldklass } || entries.count - 1
|
||||
entries.insert(i+1, Entry.new(newklass, *args)) unless exists?(newklass)
|
||||
entries.insert(i+1, new_entry)
|
||||
end
|
||||
|
||||
def exists?(klass)
|
||||
|
|
Loading…
Reference in a new issue