Sha256: f3ec95134f0651a2fdb72df690f590a4ea95762f637cb41ce8ecefae262a7d63

Contents?: true

Size: 1.35 KB

Versions: 4

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Service
    module Plugins
      module HasResultSteps
        module Concern
          include Support::Concern

          instance_methods do
            def steps
              internals.cache.fetch(:steps) do
                self.class
                  .steps
                  .tap(&:commit!)
                  .map { |step| step.copy(overrides: {kwargs: {organizer: self}}) }
              end
            end

            ##
            # TODO: Create for callbacks.
            #
            #   def step(step_result)
            #     step_result
            #   end
            #
          end

          class_methods do
            def step(*args, **kwargs)
              step_class.new(*args, **kwargs.merge(container: self))
                .tap { |step_instance| steps << step_instance }
            end

            ##
            # NOTE: Allows to pass a value to `in` method without processing it.
            #
            def raw(value)
              Entities::Method::Entities::Values::Raw.wrap(value)
            end

            def steps
              @steps ||= Entities::StepCollection.new
            end

            def step_class
              @step_class ||= Commands::CreateStepClass.call(service_class: self)
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
convenient_service-0.3.1 lib/convenient_service/service/plugins/has_result_steps/concern.rb
convenient_service-0.3.0 lib/convenient_service/service/plugins/has_result_steps/concern.rb
convenient_service-0.2.1 lib/convenient_service/service/plugins/has_result_steps/concern.rb
convenient_service-0.2.0 lib/convenient_service/service/plugins/has_result_steps/concern.rb