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.
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
#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.
32 33 34 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 32 def container @container end |
#expression ⇒ ConvenientService::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 |
#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.
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?
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
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).
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
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.
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
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
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
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 |
#inspect ⇒ 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 |
#result ⇒ ConvenientService::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 |
#size ⇒ 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_arguments ⇒ ConvenientService::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 |