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



195
196
197
198
199
200
201
202
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 195

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



70
71
72
73
74
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 70

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.



178
179
180
181
182
183
184
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 178

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.



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

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.

Parameters:

  • some_middleware (#call<Hash>)

Returns:

  • (Boolean)

Since:

  • 1.0.0



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

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.



112
113
114
115
116
117
118
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 112

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.



131
132
133
134
135
136
137
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 131

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



153
154
155
156
157
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 153

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



143
144
145
146
147
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 143

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.



165
166
167
168
169
170
171
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 165

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



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

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



80
81
82
83
84
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 80

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



95
96
97
98
99
# File 'lib/convenient_service/support/middleware/stack_builder/entities/builders/custom.rb', line 95

def use(middleware)
  stack << middleware

  self
end