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
- #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?
180 181 182 183 184 185 186 187 188 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 180 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.
163 164 165 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 163 def [](index) steps[index] end |
#commit! ⇒ Boolean
Returns true if called for the first time, false otherwise (similarly as Kernel#require).
101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 101 def commit! return false if committed? expression.each_step(&:define!).freeze steps.freeze freeze true end |
#committed? ⇒ Boolean
118 119 120 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 118 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.
74 75 76 77 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 74 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
128 129 130 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 128 def each(&block) expression.each_step(&block) end |
#each_evaluated_step(&block) ⇒ Array<ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step>, Enumerator
148 149 150 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 148 def each_evaluated_step(&block) expression.each_evaluated_step(&block) end |
#each_step(&block) ⇒ Array<ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step>, Enumerator
138 139 140 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 138 def each_step(&block) expression.each_step(&block) end |
#inspect ⇒ String
170 171 172 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 170 def inspect expression.inspect end |
#result ⇒ ConvenientService::Service::Plugins::HasJSendResult::Entities::Result
63 64 65 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 63 def result expression.result end |
#to_arguments ⇒ ConvenientService::Support::Arguments
193 194 195 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 193 def to_arguments Support::Arguments.new(container: container, expression: expression, steps: steps) end |
#with_organizer(organizer) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::StepCollection
83 84 85 86 87 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/entities/step_collection.rb', line 83 def with_organizer(organizer) expression_with_organizer = expression.with_organizer(organizer) copy(overrides: {kwargs: {expression: expression_with_organizer, steps: expression_with_organizer.steps}}) end |