Class: ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::StepCollection

Inherits:
Object
  • Object
show all
Includes:
ConvenientService::Support::Copyable, Enumerable
Defined in:
lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ConvenientService::Support::Copyable

#copy

Constructor Details

#initialize(container:, expression: Entities::Expressions::Empty.new, steps: []) ⇒ 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:



58
59
60
61
62
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 58

def initialize(container:, expression: Entities::Expressions::Empty.new, steps: [])
  @container = container
  @expression = expression
  @steps = steps
end

Instance Attribute Details

#containerObject (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.



32
33
34
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 32

def container
  @container
end

#expressionConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base



40
41
42
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 40

def expression
  @expression
end

#stepsObject (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.



48
49
50
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 48

def steps
  @steps
end

Instance Method Details

#==(other) ⇒ Boolean?

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)


196
197
198
199
200
201
202
203
204
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 196

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

  return false if container != other.container
  return false if expression != other.expression
  return false if steps != other.steps

  true
end

#[](index) ⇒ ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step

Note:

Works in a similar way as Array#[].

Returns step by index.



179
180
181
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 179

def [](index)
  steps[index]
end

#commit!Boolean

Returns true if called for the first time, false otherwise (similarly as Kernel#require).

Returns:

  • (Boolean)

    true if called for the first time, false otherwise (similarly as Kernel#require).

See Also:



117
118
119
120
121
122
123
124
125
126
127
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 117

def commit!
  return false if committed?

  expression.each_step(&:define!).freeze

  steps.freeze

  freeze

  true
end

#committed?Boolean

Returns:

  • (Boolean)


134
135
136
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 134

def committed?
  frozen?
end

#create(*args, **kwargs) ⇒ ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step

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:

  • args (Array<Object>)
  • kwargs (Hash{Symbol => Object})

Returns:



86
87
88
89
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 86

def create(*args, **kwargs)
  step_class.new(*args, **kwargs.merge(container: container, index: next_available_index))
    .tap { |step| steps << step }
end

#each(&block) ⇒ Array<ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step>, Enumerator

Parameters:

  • block (Proc, nil)

Returns:



144
145
146
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 144

def each(&block)
  expression.each_step(&block)
end

#each_evaluated_step(&block) ⇒ Array<ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step>, Enumerator

Parameters:

  • block (Proc, nil)

Returns:



164
165
166
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 164

def each_evaluated_step(&block)
  expression.each_evaluated_step(&block)
end

#each_step(&block) ⇒ Array<ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step>, Enumerator

Parameters:

  • block (Proc, nil)

Returns:



154
155
156
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 154

def each_step(&block)
  expression.each_step(&block)
end

#inspectString

Returns:

  • (String)


186
187
188
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 186

def inspect
  expression.inspect
end

#resultConvenientService::Service::Plugins::HasJSendResult::Entities::Result



75
76
77
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 75

def result
  expression.result
end

#sizeInteger

Returns:

  • (Integer)


67
68
69
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 67

def size
  steps.size
end

#to_argumentsConvenientService::Support::Arguments



209
210
211
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 209

def to_arguments
  Support::Arguments.new(container: container, expression: expression, steps: steps)
end

#with_organizer(organizer) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::StepCollection



95
96
97
98
99
100
101
102
103
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 95

def with_organizer(organizer)
  expression_with_organizer = expression.with_organizer(organizer)

  if frozen?
    copy(overrides: {kwargs: {expression: expression_with_organizer.freeze, steps: expression_with_organizer.steps.freeze}}).freeze
  else
    copy(overrides: {kwargs: {expression: expression_with_organizer, steps: expression_with_organizer.steps}})
  end
end