diff --git a/lib/grape/middleware/stack.rb b/lib/grape/middleware/stack.rb index cbe914754b..1ce5941f47 100644 --- a/lib/grape/middleware/stack.rb +++ b/lib/grape/middleware/stack.rb @@ -6,6 +6,8 @@ module Middleware # It allows to insert and insert after class Stack class Middleware + use_ruby2_keywords = Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7') + attr_reader :args, :opts, :block, :klass def initialize(klass, *args, **opts, &block) @@ -17,13 +19,13 @@ def initialize(klass, *args, **opts, &block) def use_in(builder) block ? builder.use(klass, *args, **opts, &block) : builder.use(klass, *args, **opts) - end if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7') + end if use_ruby2_keywords def use_in(builder) args = m.args args += [m.opts] unless m.opts.empty? block ? builder.use(klass, *args, &block) : builder.use(klass, *args) - end if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7') + end unless use_ruby2_keywords def name klass.name