Class: ConvenientService::Support::Middleware::StackBuilder::Entities::Builders::RubyMiddleware Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



30
31
32
33
34
35
36
37
38
39
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/ruby_middleware.rb', line 30

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

  @middleware_name = opts.fetch(:name) { "Stack" }

  ##
  # 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?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Returns:

  • (Boolean, nil)

Since:

  • 1.0.0



124
125
126
127
128
129
130
131
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/ruby_middleware.rb', line 124

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

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

  true
end

#call_with_original(env, original) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Can be any type.

Parameters:

  • env (Hash{Symbol => Object})
  • original (Proc)

Returns:

  • (Object)

    Can be any type.

Since:

  • 1.0.0



77
78
79
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/ruby_middleware.rb', line 77

def call_with_original(env, original)
  dup.use(original).call(env)
end

#clearBoolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 1.0.0



63
64
65
66
67
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/ruby_middleware.rb', line 63

def clear
  stack.clear

  self
end

#dupConvenientService::Support::Middleware::StackBuilder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/ruby_middleware.rb', line 152

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

#empty?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 1.0.0



44
45
46
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/ruby_middleware.rb', line 44

def empty?
  stack.empty?
end

#has?(some_middleware) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

rubocop:disable Performance/RedundantEqualityComparisonBlock

Parameters:

  • some_middleware (#call<Hash>)

Returns:

  • (Boolean)

    NOTE: any?(arg) compares with ===. For this method == is mandatory.

Since:

  • 1.0.0



55
56
57
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/ruby_middleware.rb', line 55

def has?(some_middleware)
  stack.any? { |middleware| middleware == [some_middleware, [], nil] }
end

#to_aArray

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Array)

Since:

  • 1.0.0



142
143
144
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/ruby_middleware.rb', line 142

def to_a
  stack.map(&:first)
end

#unshift(middleware, *args, &block) ⇒ ConvenientService::Support::Middleware::StackBuilder::Entities::Builders::RubyMiddleware Also known as: prepend

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • middleware (#call<Hash>)
  • args (Array<Object>)
  • block (Proc, nil)

Returns:

Since:

  • 1.0.0



90
91
92
93
94
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/ruby_middleware.rb', line 90

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

  self
end