From 2a3c47ff5d4ed7391d8a2d02a6baa1f1f55a8df3 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 7 Aug 2015 15:35:39 -0700 Subject: finish deprecating handling strings and symbols since we only work with instances of classes, it greatly simplifies the `Middleware` implementation. --- actionpack/lib/action_dispatch/middleware/stack.rb | 23 ++++------------------ 1 file changed, 4 insertions(+), 19 deletions(-) (limited to 'actionpack/lib/action_dispatch') diff --git a/actionpack/lib/action_dispatch/middleware/stack.rb b/actionpack/lib/action_dispatch/middleware/stack.rb index 62e87a6f29..0430ce3b9a 100644 --- a/actionpack/lib/action_dispatch/middleware/stack.rb +++ b/actionpack/lib/action_dispatch/middleware/stack.rb @@ -14,17 +14,6 @@ module ActionDispatch def name; klass.name; end - def ==(middleware) - case middleware - when Middleware - klass == middleware.klass - when Class - klass == middleware - else - normalize(name) == normalize(middleware) - end - end - def inspect klass.to_s end @@ -32,12 +21,6 @@ module ActionDispatch def build(app) klass.new(app, *args, &block) end - - private - - def normalize(object) - object.to_s.strip.sub(/^::/, '') - end end include Enumerable @@ -92,7 +75,8 @@ module ActionDispatch end def delete(target) - middlewares.delete target + target = get_class target + middlewares.delete_if { |m| m.klass == target } end def use(klass, *args, &block) @@ -106,7 +90,8 @@ module ActionDispatch protected def assert_index(index, where) - i = index.is_a?(Integer) ? index : middlewares.index(index) + index = get_class index + i = index.is_a?(Integer) ? index : middlewares.index { |m| m.klass == index } raise "No such middleware to insert #{where}: #{index.inspect}" unless i i end -- cgit v1.2.3