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

Inherits:
Object
  • Object
show all
Includes:
AbstractMethod
Defined in:
lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb,
lib/convenient_service/support/middleware/stack_builder/entities/builders/custom/constants.rb,
lib/convenient_service/support/middleware/stack_builder/entities/builders/custom/exceptions.rb,
lib/convenient_service/support/middleware/stack_builder/entities/builders/custom/entities/proc_with_new.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

Direct Known Subclasses

Naive, Rack, Stateful

Defined Under Namespace

Modules: Constants, Entities, Exceptions

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AbstractMethod

abstract_method

Methods included from Concern

included

Constructor Details

#initialize(**kwargs) ⇒ 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.

Parameters:

  • kwargs (Hash{Symbol => Object})

Since:

  • 1.0.0



47
48
49
50
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 47

def initialize(**kwargs)
  @name = kwargs.fetch(:name) { "Stack" }
  @stack = kwargs.fetch(:stack) { [] }
end

Instance Attribute Details

#nameObject (readonly)

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.

Since:

  • 1.0.0



31
32
33
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 31

def name
  @name
end

#stackObject (readonly)

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.

Since:

  • 1.0.0



25
26
27
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 25

def stack
  @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:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)

Since:

  • 1.0.0



199
200
201
202
203
204
205
206
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 199

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

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

  true
end

#callObject

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.

Returns:

  • (Object)

    Can be any type.

Since:

  • 1.0.0



41
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 41

abstract_method :call

#call_with_originalObject

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.

Returns:

  • (Object)

    Can be any type.

Since:

  • 1.0.0



36
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 36

abstract_method :call_with_original

#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



74
75
76
77
78
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 74

def clear
  stack.clear

  self
end

#delete(index_or_middleware) ⇒ ConvenientService::Support::Middleware::StackBuilder::Entities::Builders::Custom Also known as: remove

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.



182
183
184
185
186
187
188
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 182

def delete(index_or_middleware)
  index = cast_index(index_or_middleware)

  stack.delete_at(index)

  self
end

#dupConvenientService::Support::Middleware::StackBuilder::Entities::Builders::Custom

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.



218
219
220
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 218

def dup
  self.class.new(name: name.dup, 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



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

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



66
67
68
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 66

def has?(some_middleware)
  stack.any? { |middleware| middleware == some_middleware }
end

#insert(index_or_middleware, other_middleware) ⇒ ConvenientService::Support::Middleware::StackBuilder::Entities::Builders::Custom Also known as: insert_before

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.



116
117
118
119
120
121
122
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 116

def insert(index_or_middleware, other_middleware)
  index = cast_index(index_or_middleware)

  stack.insert(index, other_middleware)

  self
end

#insert_after(index_or_middleware, other_middleware) ⇒ ConvenientService::Support::Middleware::StackBuilder::Entities::Builders::Custom

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.



135
136
137
138
139
140
141
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 135

def insert_after(index_or_middleware, other_middleware)
  index = cast_index(index_or_middleware)

  stack.insert(index + 1, other_middleware)

  self
end

#insert_after_each(other_middleware) ⇒ ConvenientService::Support::Middleware::StackBuilder::Entities::Builders::Custom

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:

  • other_middleware (#call<Hash>)

Returns:

Since:

  • 1.0.0



157
158
159
160
161
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 157

def insert_after_each(other_middleware)
  @stack = stack.reduce([]) { |stack, middleware| stack.push(middleware, other_middleware) }

  self
end

#insert_before_each(other_middleware) ⇒ ConvenientService::Support::Middleware::StackBuilder::Entities::Builders::Custom

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:

  • other_middleware (#call<Hash>)

Returns:

Since:

  • 1.0.0



147
148
149
150
151
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 147

def insert_before_each(other_middleware)
  @stack = stack.reduce([]) { |stack, middleware| stack.push(other_middleware, middleware) }

  self
end

#replace(index_or_middleware, other_middleware) ⇒ ConvenientService::Support::Middleware::StackBuilder::Entities::Builders::Custom

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.



169
170
171
172
173
174
175
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 169

def replace(index_or_middleware, other_middleware)
  index = cast_index(index_or_middleware)

  stack[index] = other_middleware

  self
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



211
212
213
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 211

def to_a
  stack
end

#unshift(middleware) ⇒ ConvenientService::Support::Middleware::StackBuilder::Entities::Builders::Custom 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>)

Returns:

Since:

  • 1.0.0



84
85
86
87
88
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 84

def unshift(middleware)
  stack.unshift(middleware)

  self
end

#use(middleware) ⇒ ConvenientService::Support::Middleware::StackBuilder::Entities::Builders::Custom Also known as: append

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>)

Returns:

Since:

  • 1.0.0



99
100
101
102
103
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 99

def use(middleware)
  stack << middleware

  self
end