Sha256: e985a4ee11d0f5f4997cd6457063b1e229fb3173263e53d8e95d3c34645c1089

Contents?: true

Size: 1.18 KB

Versions: 8

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Service
    module Plugins
      module HasResultSteps
        module Entities
          class StepCollection
            include ::Enumerable

            attr_reader :steps

            def initialize
              @steps = []
            end

            ##
            # TODO: Specs.
            #
            def commit!
              return false if committed?

              steps.each { |step| step.validate! && step.define! }.freeze

              true
            end

            ##
            # TODO: Specs.
            #
            def committed?
              steps.frozen?
            end

            def each(&block)
              steps.each(&block)
            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

8 entries across 8 versions & 1 rubygems

Version Path
convenient_service-0.6.0 lib/convenient_service/service/plugins/has_result_steps/entities/step_collection.rb
convenient_service-0.5.0 lib/convenient_service/service/plugins/has_result_steps/entities/step_collection.rb
convenient_service-0.4.0 lib/convenient_service/service/plugins/has_result_steps/entities/step_collection.rb
convenient_service-0.3.1 lib/convenient_service/service/plugins/has_result_steps/entities/step_collection.rb
convenient_service-0.3.0 lib/convenient_service/service/plugins/has_result_steps/entities/step_collection.rb
convenient_service-0.2.1 lib/convenient_service/service/plugins/has_result_steps/entities/step_collection.rb
convenient_service-0.2.0 lib/convenient_service/service/plugins/has_result_steps/entities/step_collection.rb
convenient_service-0.1.0 lib/convenient_service/service/plugins/has_result_steps/entities/step_collection.rb