Sha256: 1903e2c28d43535690d45fd0fdc309025ae1dd8939d4b8d642b72f904b99f624
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
# frozen_string_literal: true module ConvenientService module Service module Plugins module CanHaveSteps module Entities class StepCollection include ::Enumerable attr_reader :steps def initialize @steps = [] end ## # TODO: Specs. # def commit! return false if committed? ## # IMPORTANT: Temporarily removed `step.validate!` since it is neither thread-safe nor idempotent. # steps.each { |step| step.define! }.freeze true end ## # TODO: Specs. # def committed? steps.frozen? end def each(&block) steps.each(&block) end ## # Returns step by index. # # @param index [Integer] # @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step] # # @note Works in a similar way as `Array#[]`. # @see https://ruby-doc.org/core-2.7.0/Array.html#method-i-5B-5D # def [](index) steps[index] end def <<(step) steps << step.copy(overrides: {kwargs: {index: next_available_index}}) end def ==(other) return unless other.instance_of?(self.class) return false if steps != other.steps true end private def next_available_index steps.size end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
convenient_service-0.11.0 | lib/convenient_service/service/plugins/can_have_steps/entities/step_collection.rb |