Class: ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::StepCollection
- Inherits:
-
Object
- Object
- ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::StepCollection
- Includes:
- ConvenientService::Support::Copyable, Enumerable
- Defined in:
- lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb
Instance Attribute Summary collapse
- #container ⇒ Object readonly private
- #expression ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
- #steps ⇒ Object readonly private
Instance Method Summary collapse
- #==(other) ⇒ Boolean?
-
#[](index) ⇒ ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step
Returns step by index.
-
#commit! ⇒ Boolean
True if called for the first time, false otherwise (similarly as Kernel#require).
- #committed? ⇒ Boolean
- #create(*args, **kwargs) ⇒ ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step private
- #each(&block) ⇒ Array<ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step>, Enumerator
- #each_evaluated_step(&block) ⇒ Array<ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step>, Enumerator
- #each_step(&block) ⇒ Array<ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step>, Enumerator
- #initialize(container:, expression: Entities::Expressions::Empty.new, steps: []) ⇒ void constructor private
- #inspect ⇒ String
- #result ⇒ ConvenientService::Service::Plugins::HasJSendResult::Entities::Result
- #size ⇒ Integer
- #to_arguments ⇒ ConvenientService::Support::Arguments
- #with_organizer(organizer) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::StepCollection
Methods included from ConvenientService::Support::Copyable
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.
53 54 55 56 57 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 53 def initialize(container:, expression: Entities::Expressions::Empty.new, steps: []) @container = container @expression = expression @steps = steps end |
Instance Attribute Details
#container ⇒ Object (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.
27 28 29 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 27 def container @container end |
#expression ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
35 36 37 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 35 def expression @expression end |
#steps ⇒ Object (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.
43 44 45 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 43 def steps @steps end |
Instance Method Details
#==(other) ⇒ Boolean?
187 188 189 190 191 192 193 194 195 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 187 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
Works in a similar way as Array#[]
.
Returns step by index.
170 171 172 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 170 def [](index) steps[index] end |
#commit! ⇒ Boolean
Returns true if called for the first time, false otherwise (similarly as Kernel#require).
108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 108 def commit! return false if committed? expression.each_step(&:define!).freeze steps.freeze freeze true end |
#committed? ⇒ Boolean
125 126 127 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 125 def committed? expression.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.
81 82 83 84 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 81 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
135 136 137 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 135 def each(&block) expression.each_step(&block) end |
#each_evaluated_step(&block) ⇒ Array<ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step>, Enumerator
155 156 157 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 155 def each_evaluated_step(&block) expression.each_evaluated_step(&block) end |
#each_step(&block) ⇒ Array<ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step>, Enumerator
145 146 147 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 145 def each_step(&block) expression.each_step(&block) end |
#inspect ⇒ String
177 178 179 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 177 def inspect expression.inspect end |
#result ⇒ ConvenientService::Service::Plugins::HasJSendResult::Entities::Result
70 71 72 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 70 def result expression.result end |
#size ⇒ Integer
62 63 64 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 62 def size steps.size end |
#to_arguments ⇒ ConvenientService::Support::Arguments
200 201 202 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 200 def to_arguments Support::Arguments.new(container: container, expression: expression, steps: steps) end |
#with_organizer(organizer) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::StepCollection
90 91 92 93 94 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 90 def with_organizer(organizer) expression_with_organizer = expression.with_organizer(organizer) copy(overrides: {kwargs: {expression: expression_with_organizer, steps: expression_with_organizer.steps}}) end |