Class: Grape::Middleware::Stack::Middleware
- Inherits:
-
Object
- Object
- Grape::Middleware::Stack::Middleware
- Defined in:
- lib/grape/middleware/stack.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #build(builder) ⇒ Object
-
#initialize(klass, args, block) ⇒ Middleware
constructor
A new instance of Middleware.
- #inspect ⇒ Object
- #name ⇒ Object
Constructor Details
#initialize(klass, args, block) ⇒ Middleware
Returns a new instance of Middleware.
13 14 15 16 17 |
# File 'lib/grape/middleware/stack.rb', line 13 def initialize(klass, args, block) @klass = klass @args = args @block = block end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
11 12 13 |
# File 'lib/grape/middleware/stack.rb', line 11 def args @args end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
11 12 13 |
# File 'lib/grape/middleware/stack.rb', line 11 def block @block end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
11 12 13 |
# File 'lib/grape/middleware/stack.rb', line 11 def klass @klass end |
Instance Method Details
#==(other) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/grape/middleware/stack.rb', line 23 def ==(other) case other when Middleware klass == other.klass when Class klass == other || (name.nil? && klass.superclass == other) end end |
#build(builder) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/grape/middleware/stack.rb', line 36 def build(builder) # we need to force the ruby2_keywords_hash for middlewares that initialize contains keywords # like ActionDispatch::RequestId since middleware arguments are serialized # https://rubyapi.org/3.4/o/hash#method-c-ruby2_keywords_hash args[-1] = Hash.ruby2_keywords_hash(args[-1]) if args.last.is_a?(Hash) && Hash.respond_to?(:ruby2_keywords_hash) builder.use(klass, *args, &block) end |
#inspect ⇒ Object
32 33 34 |
# File 'lib/grape/middleware/stack.rb', line 32 def inspect klass.to_s end |
#name ⇒ Object
19 20 21 |
# File 'lib/grape/middleware/stack.rb', line 19 def name klass.name end |