Class: ConvenientService::Support::Middleware::StackBuilder

Inherits:
Dependencies::Extractions::RubyMiddleware::Middleware::Builder show all
Defined in:
lib/convenient_service/support/middleware/stack_builder.rb

Instance Method Summary collapse

Methods inherited from Dependencies::Extractions::RubyMiddleware::Middleware::Builder

#call, #delete, #flatten, #inject_logger, #insert, #insert_after, #insert_after_each, #insert_before_each, #inspect, #name, #replace, #use

Constructor Details

#initialize(opts = {}, &block) ⇒ void

Parameters:

  • opts (Hash) (defaults to: {})
  • block (Proc, nil)

See Also:



24
25
26
27
28
29
30
31
# File 'lib/convenient_service/support/middleware/stack_builder.rb', line 24

def initialize(opts = {}, &block)
  super

  ##
  # https://github.com/marian13/ruby-middleware/blob/v0.4.2/lib/middleware/builder.rb#L174
  #
  self.stack = opts[:stack] if opts.has_key?(:stack)
end

Instance Method Details

#==(other) ⇒ Boolean?

Parameters:

Returns:

  • (Boolean, nil)


68
69
70
71
72
73
74
75
# File 'lib/convenient_service/support/middleware/stack_builder.rb', line 68

def ==(other)
  return unless other.instance_of?(self.class)

  return false if name != other.name
  return false if stack != other.stack

  true
end

#dupConvenientService::Support::Middleware::StackBuilder



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/convenient_service/support/middleware/stack_builder.rb', line 96

def dup
  self.class.new(
    ##
    # https://github.com/marian13/ruby-middleware/blob/v0.4.2/lib/middleware/builder.rb#L45
    #
    runner_class: @runner_class,
    ##
    # https://github.com/marian13/ruby-middleware/blob/v0.4.2/lib/middleware/builder.rb#L46
    #
    name: @middleware_name.dup,
    ##
    # https://github.com/marian13/ruby-middleware/blob/v0.4.2/lib/middleware/builder.rb#L167
    #
    stack: stack.dup
  )
end

#to_aArray

Returns:

  • (Array)


86
87
88
# File 'lib/convenient_service/support/middleware/stack_builder.rb', line 86

def to_a
  stack
end

#unshift(middleware, *args, &block) ⇒ ConvenientService::Core::Entities::Config::Entities::MethodMiddlewares::Entities::Stack Also known as: prepend



42
43
44
45
46
# File 'lib/convenient_service/support/middleware/stack_builder.rb', line 42

def unshift(middleware, *args, &block)
  stack.unshift([middleware, args, block])

  self
end