Skip to content
Permalink
Browse files

Use ruby2_keywords for ActionDispatch::MiddlewareStack

  • Loading branch information
eregon committed Oct 24, 2019
1 parent f414dd5 commit 44a80647f56e98ae008d45fadde53f2db354902c
Showing with 12 additions and 5 deletions.
  1. +12 −5 actionpack/lib/action_dispatch/middleware/stack.rb
@@ -3,6 +3,13 @@
require "active_support/inflector/methods"
require "active_support/dependencies"

class Module
unless respond_to?(:ruby2_keywords, true)
def self.ruby2_keywords(*)
end
end
end

module ActionDispatch
class MiddlewareStack
class Middleware
@@ -88,27 +95,27 @@ def [](i)
middlewares[i]
end

def unshift(klass, *args, &block)
ruby2_keywords def unshift(klass, *args, &block)
middlewares.unshift(build_middleware(klass, args, block))
end

def initialize_copy(other)
self.middlewares = other.middlewares.dup
end

def insert(index, klass, *args, &block)
ruby2_keywords def insert(index, klass, *args, &block)
index = assert_index(index, :before)
middlewares.insert(index, build_middleware(klass, args, block))
end

alias_method :insert_before, :insert

def insert_after(index, *args, &block)
ruby2_keywords def insert_after(index, *args, &block)
index = assert_index(index, :after)
insert(index + 1, *args, &block)
end

def swap(target, *args, &block)
ruby2_keywords def swap(target, *args, &block)
index = assert_index(target, :before)
insert(index, *args, &block)
middlewares.delete_at(index + 1)
@@ -118,7 +125,7 @@ def delete(target)
middlewares.delete_if { |m| m.klass == target }
end

def use(klass, *args, &block)
ruby2_keywords def use(klass, *args, &block)
middlewares.push(build_middleware(klass, args, block))
end

0 comments on commit 44a8064

Please sign in to comment.
You can’t perform that action at this time.