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
|
end
|
||||||
|
|
||||||
def insert_before(*args, &block)
|
def insert_before(*args, &block)
|
||||||
@operations << -> middleware { middleware.send(__method__, *args, &block) }
|
@operations << -> middleware { middleware.insert_before(*args, &block) }
|
||||||
end
|
end
|
||||||
ruby2_keywords(:insert_before) if respond_to?(:ruby2_keywords, true)
|
ruby2_keywords(:insert_before) if respond_to?(:ruby2_keywords, true)
|
||||||
|
|
||||||
alias :insert :insert_before
|
alias :insert :insert_before
|
||||||
|
|
||||||
def insert_after(*args, &block)
|
def insert_after(*args, &block)
|
||||||
@operations << -> middleware { middleware.send(__method__, *args, &block) }
|
@operations << -> middleware { middleware.insert_after(*args, &block) }
|
||||||
end
|
end
|
||||||
ruby2_keywords(:insert_after) if respond_to?(:ruby2_keywords, true)
|
ruby2_keywords(:insert_after) if respond_to?(:ruby2_keywords, true)
|
||||||
|
|
||||||
def swap(*args, &block)
|
def swap(*args, &block)
|
||||||
@operations << -> middleware { middleware.send(__method__, *args, &block) }
|
@operations << -> middleware { middleware.swap(*args, &block) }
|
||||||
end
|
end
|
||||||
ruby2_keywords(:swap) if respond_to?(:ruby2_keywords, true)
|
ruby2_keywords(:swap) if respond_to?(:ruby2_keywords, true)
|
||||||
|
|
||||||
def use(*args, &block)
|
def use(*args, &block)
|
||||||
@operations << -> middleware { middleware.send(__method__, *args, &block) }
|
@operations << -> middleware { middleware.use(*args, &block) }
|
||||||
end
|
end
|
||||||
ruby2_keywords(:use) if respond_to?(:ruby2_keywords, true)
|
ruby2_keywords(:use) if respond_to?(:ruby2_keywords, true)
|
||||||
|
|
||||||
def delete(*args, &block)
|
def delete(*args, &block)
|
||||||
@delete_operations << -> middleware { middleware.send(__method__, *args, &block) }
|
@delete_operations << -> middleware { middleware.delete(*args, &block) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def move_before(*args, &block)
|
def move_before(*args, &block)
|
||||||
@delete_operations << -> middleware { middleware.send(__method__, *args, &block) }
|
@delete_operations << -> middleware { middleware.move_before(*args, &block) }
|
||||||
end
|
end
|
||||||
|
|
||||||
alias :move :move_before
|
alias :move :move_before
|
||||||
|
|
||||||
def move_after(*args, &block)
|
def move_after(*args, &block)
|
||||||
@delete_operations << -> middleware { middleware.send(__method__, *args, &block) }
|
@delete_operations << -> middleware { middleware.move_after(*args, &block) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def unshift(*args, &block)
|
def unshift(*args, &block)
|
||||||
@operations << -> middleware { middleware.send(__method__, *args, &block) }
|
@operations << -> middleware { middleware.unshift(*args, &block) }
|
||||||
end
|
end
|
||||||
ruby2_keywords(:unshift) if respond_to?(:ruby2_keywords, true)
|
ruby2_keywords(:unshift) if respond_to?(:ruby2_keywords, true)
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,8 @@ module Rails
|
||||||
@stack.delete :foo
|
@stack.delete :foo
|
||||||
|
|
||||||
mock = Minitest::Mock.new
|
mock = Minitest::Mock.new
|
||||||
mock.expect :send, nil, [:swap, :foo]
|
mock.expect :swap, nil, [:foo]
|
||||||
mock.expect :send, nil, [:delete, :foo]
|
mock.expect :delete, nil, [:foo]
|
||||||
|
|
||||||
@stack.merge_into mock
|
@stack.merge_into mock
|
||||||
mock.verify
|
mock.verify
|
||||||
|
@ -73,7 +73,7 @@ module Rails
|
||||||
private
|
private
|
||||||
def assert_playback(msg_name, args)
|
def assert_playback(msg_name, args)
|
||||||
mock = Minitest::Mock.new
|
mock = Minitest::Mock.new
|
||||||
mock.expect :send, nil, [msg_name, args]
|
mock.expect msg_name, nil, [args]
|
||||||
@stack.merge_into(mock)
|
@stack.merge_into(mock)
|
||||||
mock.verify
|
mock.verify
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue