From a412e4da648e1c740d26c0e75dbf4c0e202391e8 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Wed, 7 Oct 2020 04:58:46 +0900 Subject: [PATCH] Get rid of unnecessary meta programming Each stacked operation is a Proc object instead of operation name since fedde239dcee256b417dc9bcfe5fef603bf0d952, and so we can now simply inline the target method for each operation --- railties/lib/rails/configuration.rb | 16 ++++++++-------- .../configuration/middleware_stack_proxy_test.rb | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index e097f5dde8..830c059e5f 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -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) diff --git a/railties/test/configuration/middleware_stack_proxy_test.rb b/railties/test/configuration/middleware_stack_proxy_test.rb index a40ec8f8e5..6131cdd690 100644 --- a/railties/test/configuration/middleware_stack_proxy_test.rb +++ b/railties/test/configuration/middleware_stack_proxy_test.rb @@ -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