Class: Grape::Middleware::Stack::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/grape/middleware/stack.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, *args, **opts, &block) ⇒ Middleware

Returns a new instance of Middleware.


11
12
13
14
15
16
# File 'lib/grape/middleware/stack.rb', line 11

def initialize(klass, *args, **opts, &block)
  @klass = klass
  @args  = args
  @opts  = opts
  @block = block
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args


9
10
11
# File 'lib/grape/middleware/stack.rb', line 9

def args
  @args
end

#blockObject (readonly)

Returns the value of attribute block


9
10
11
# File 'lib/grape/middleware/stack.rb', line 9

def block
  @block
end

#klassObject (readonly)

Returns the value of attribute klass


9
10
11
# File 'lib/grape/middleware/stack.rb', line 9

def klass
  @klass
end

#optsObject (readonly)

Returns the value of attribute opts


9
10
11
# File 'lib/grape/middleware/stack.rb', line 9

def opts
  @opts
end

Instance Method Details

#==(other) ⇒ Object


22
23
24
25
26
27
28
29
# File 'lib/grape/middleware/stack.rb', line 22

def ==(other)
  case other
  when Middleware
    klass == other.klass
  when Class
    klass == other || (name.nil? && klass.superclass == other)
  end
end

#inspectObject


31
32
33
# File 'lib/grape/middleware/stack.rb', line 31

def inspect
  klass.to_s
end

#nameObject


18
19
20
# File 'lib/grape/middleware/stack.rb', line 18

def name
  klass.name
end

#use_in(builder) ⇒ Object


36
37
38
# File 'lib/grape/middleware/stack.rb', line 36

def use_in(builder)
  block ? builder.use(klass, *args, **opts, &block) : builder.use(klass, *args, **opts)
end