Class: ConvenientService::Service::Plugins::CanHaveSteps::Entities::StepCollection
- Inherits:
-
Object
- Object
- ConvenientService::Service::Plugins::CanHaveSteps::Entities::StepCollection
- Includes:
- Enumerable
- Defined in:
- lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb
Instance Attribute Summary collapse
- #steps ⇒ Object readonly private
Instance Method Summary collapse
- #<<(step) ⇒ ConvenientService::Service::Plugins::CanHaveSteps::Entities::StepCollection private
- #==(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
- #each(&block) ⇒ Array<ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step>, Enumerator
- #initialize(steps: []) ⇒ void constructor private
Constructor Details
#initialize(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.
25 26 27 |
# File 'lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb', line 25 def initialize(steps: []) @steps = steps end |
Instance Attribute Details
#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.
17 18 19 |
# File 'lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb', line 17 def steps @steps end |
Instance Method Details
#<<(step) ⇒ ConvenientService::Service::Plugins::CanHaveSteps::Entities::StepCollection
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.
89 90 91 92 93 |
# File 'lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb', line 89 def <<(step) steps << step.copy(overrides: {kwargs: {index: next_available_index}}) self end |
#==(other) ⇒ Boolean?
101 102 103 104 105 106 107 |
# File 'lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb', line 101 def ==(other) return unless other.instance_of?(self.class) 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.
79 80 81 |
# File 'lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb', line 79 def [](index) steps[index] end |
#commit! ⇒ Boolean
Returns true if called for the first time, false otherwise (similarly as Kernel#require).
41 42 43 44 45 46 47 |
# File 'lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb', line 41 def commit! return false if committed? steps.each(&:define!).freeze true end |
#committed? ⇒ Boolean
54 55 56 |
# File 'lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb', line 54 def committed? steps.frozen? end |
#each(&block) ⇒ Array<ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step>, Enumerator
64 65 66 |
# File 'lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb', line 64 def each(&block) steps.each(&block) end |