Class: ConvenientService::Service::Plugins::CanHaveSequentialSteps::Entities::StepCollection
- Inherits:
-
Object
- Object
- ConvenientService::Service::Plugins::CanHaveSequentialSteps::Entities::StepCollection
- Includes:
- ConvenientService::Support::Copyable, Enumerable
- Defined in:
- lib/convenient_service/service/plugins/can_have_sequential_steps/entities/step_collection.rb
Instance Attribute Summary collapse
- #container ⇒ Object readonly private
- #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
- #initialize(container:, steps: []) ⇒ void constructor private
- #inspect ⇒ String
- #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:, 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.
36 37 38 39 |
# File 'lib/convenient_service/service/plugins/can_have_sequential_steps/entities/step_collection.rb', line 36 def initialize(container:, steps: []) @container = container @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.
19 20 21 |
# File 'lib/convenient_service/service/plugins/can_have_sequential_steps/entities/step_collection.rb', line 19 def container @container 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.
27 28 29 |
# File 'lib/convenient_service/service/plugins/can_have_sequential_steps/entities/step_collection.rb', line 27 def steps @steps end |
Instance Method Details
#==(other) ⇒ Boolean?
137 138 139 140 141 142 143 144 |
# File 'lib/convenient_service/service/plugins/can_have_sequential_steps/entities/step_collection.rb', line 137 def ==(other) return unless other.instance_of?(self.class) return false if container != other.container 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.
120 121 122 |
# File 'lib/convenient_service/service/plugins/can_have_sequential_steps/entities/step_collection.rb', line 120 def [](index) steps[index] end |
#commit! ⇒ Boolean
Returns true if called for the first time, false otherwise (similarly as Kernel#require).
80 81 82 83 84 85 86 87 88 |
# File 'lib/convenient_service/service/plugins/can_have_sequential_steps/entities/step_collection.rb', line 80 def commit! return false if committed? steps.each(&:define!).freeze freeze true end |
#committed? ⇒ Boolean
95 96 97 |
# File 'lib/convenient_service/service/plugins/can_have_sequential_steps/entities/step_collection.rb', line 95 def committed? steps.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.
55 56 57 58 |
# File 'lib/convenient_service/service/plugins/can_have_sequential_steps/entities/step_collection.rb', line 55 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
105 106 107 |
# File 'lib/convenient_service/service/plugins/can_have_sequential_steps/entities/step_collection.rb', line 105 def each(&block) steps.each(&block) end |
#inspect ⇒ String
127 128 129 |
# File 'lib/convenient_service/service/plugins/can_have_sequential_steps/entities/step_collection.rb', line 127 def inspect steps.inspect end |
#size ⇒ Integer
44 45 46 |
# File 'lib/convenient_service/service/plugins/can_have_sequential_steps/entities/step_collection.rb', line 44 def size steps.size end |
#to_arguments ⇒ ConvenientService::Support::Arguments
149 150 151 |
# File 'lib/convenient_service/service/plugins/can_have_sequential_steps/entities/step_collection.rb', line 149 def to_arguments Support::Arguments.new(container: container, steps: steps) end |
#with_organizer(organizer) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::StepCollection
64 65 66 |
# File 'lib/convenient_service/service/plugins/can_have_sequential_steps/entities/step_collection.rb', line 64 def with_organizer(organizer) copy(overrides: {kwargs: {steps: steps.map { |step| step.with_organizer(organizer) }}}) end |