mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Change #add_before and #add_after to #insert_before and #insert_after
This commit is contained in:
parent
feb040717f
commit
71931fc0e1
2 changed files with 6 additions and 6 deletions
|
@ -27,7 +27,7 @@ module Sidekiq
|
|||
#
|
||||
# Sidekiq.configure_client do |config|
|
||||
# config.client_middleware do |chain|
|
||||
# chain.add_before ActiveRecord, MyClientHook
|
||||
# chain.insert_before ActiveRecord, MyClientHook
|
||||
# end
|
||||
# end
|
||||
#
|
||||
|
@ -35,7 +35,7 @@ module Sidekiq
|
|||
#
|
||||
# Sidekiq.configure_client do |config|
|
||||
# config.client_middleware do |chain|
|
||||
# chain.add_after ActiveRecord, MyClientHook
|
||||
# chain.insert_after ActiveRecord, MyClientHook
|
||||
# end
|
||||
# end
|
||||
#
|
||||
|
@ -76,12 +76,12 @@ module Sidekiq
|
|||
entries << Entry.new(klass, *args) unless exists?(klass)
|
||||
end
|
||||
|
||||
def add_before(oldklass, newklass, *args)
|
||||
def insert_before(oldklass, newklass, *args)
|
||||
i = entries.find_index { |entry| entry.klass == oldklass } || 0
|
||||
entries.insert(i, Entry.new(newklass, *args)) unless exists?(newklass)
|
||||
end
|
||||
|
||||
def add_after(oldklass, newklass, *args)
|
||||
def insert_after(oldklass, newklass, *args)
|
||||
i = entries.find_index { |entry| entry.klass == oldklass } || entries.count - 1
|
||||
entries.insert(i+1, Entry.new(newklass, *args)) unless exists?(newklass)
|
||||
end
|
||||
|
|
|
@ -74,8 +74,8 @@ class TestMiddleware < MiniTest::Unit::TestCase
|
|||
Sidekiq.server_middleware do |chain|
|
||||
# should only add once, second should be ignored
|
||||
2.times { |i| chain.add CustomMiddleware, i.to_s, $recorder }
|
||||
chain.add_before CustomMiddleware, AnotherCustomMiddleware, '2', $recorder
|
||||
chain.add_after AnotherCustomMiddleware, YetAnotherCustomMiddleware, '3', $recorder
|
||||
chain.insert_before CustomMiddleware, AnotherCustomMiddleware, '2', $recorder
|
||||
chain.insert_after AnotherCustomMiddleware, YetAnotherCustomMiddleware, '3', $recorder
|
||||
end
|
||||
|
||||
boss = MiniTest::Mock.new
|
||||
|
|
Loading…
Add table
Reference in a new issue