mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Get rid of unnecessary meta programming
Each stacked operation is a Proc object instead of operation name since fedde239dc
,
and so we can now simply inline the target method for each operation
This commit is contained in:
parent
87dfa8617c
commit
a412e4da64
2 changed files with 11 additions and 11 deletions
|
@ -50,43 +50,43 @@ module Rails
|
|||
end
|
||||
|
||||
def insert_before(*args, &block)
|
||||
@operations << -> middleware { middleware.send(__method__, *args, &block) }
|
||||
@operations << -> middleware { middleware.insert_before(*args, &block) }
|
||||
end
|
||||
ruby2_keywords(:insert_before) if respond_to?(:ruby2_keywords, true)
|
||||
|
||||
alias :insert :insert_before
|
||||
|
||||
def insert_after(*args, &block)
|
||||
@operations << -> middleware { middleware.send(__method__, *args, &block) }
|
||||
@operations << -> middleware { middleware.insert_after(*args, &block) }
|
||||
end
|
||||
ruby2_keywords(:insert_after) if respond_to?(:ruby2_keywords, true)
|
||||
|
||||
def swap(*args, &block)
|
||||
@operations << -> middleware { middleware.send(__method__, *args, &block) }
|
||||
@operations << -> middleware { middleware.swap(*args, &block) }
|
||||
end
|
||||
ruby2_keywords(:swap) if respond_to?(:ruby2_keywords, true)
|
||||
|
||||
def use(*args, &block)
|
||||
@operations << -> middleware { middleware.send(__method__, *args, &block) }
|
||||
@operations << -> middleware { middleware.use(*args, &block) }
|
||||
end
|
||||
ruby2_keywords(:use) if respond_to?(:ruby2_keywords, true)
|
||||
|
||||
def delete(*args, &block)
|
||||
@delete_operations << -> middleware { middleware.send(__method__, *args, &block) }
|
||||
@delete_operations << -> middleware { middleware.delete(*args, &block) }
|
||||
end
|
||||
|
||||
def move_before(*args, &block)
|
||||
@delete_operations << -> middleware { middleware.send(__method__, *args, &block) }
|
||||
@delete_operations << -> middleware { middleware.move_before(*args, &block) }
|
||||
end
|
||||
|
||||
alias :move :move_before
|
||||
|
||||
def move_after(*args, &block)
|
||||
@delete_operations << -> middleware { middleware.send(__method__, *args, &block) }
|
||||
@delete_operations << -> middleware { middleware.move_after(*args, &block) }
|
||||
end
|
||||
|
||||
def unshift(*args, &block)
|
||||
@operations << -> middleware { middleware.send(__method__, *args, &block) }
|
||||
@operations << -> middleware { middleware.unshift(*args, &block) }
|
||||
end
|
||||
ruby2_keywords(:unshift) if respond_to?(:ruby2_keywords, true)
|
||||
|
||||
|
|
|
@ -63,8 +63,8 @@ module Rails
|
|||
@stack.delete :foo
|
||||
|
||||
mock = Minitest::Mock.new
|
||||
mock.expect :send, nil, [:swap, :foo]
|
||||
mock.expect :send, nil, [:delete, :foo]
|
||||
mock.expect :swap, nil, [:foo]
|
||||
mock.expect :delete, nil, [:foo]
|
||||
|
||||
@stack.merge_into mock
|
||||
mock.verify
|
||||
|
@ -73,7 +73,7 @@ module Rails
|
|||
private
|
||||
def assert_playback(msg_name, args)
|
||||
mock = Minitest::Mock.new
|
||||
mock.expect :send, nil, [msg_name, args]
|
||||
mock.expect msg_name, nil, [args]
|
||||
@stack.merge_into(mock)
|
||||
mock.verify
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue