Sha256: 1ea1d46b0aed92ddf2aeee281ebd72bf44b689ef9cea017b42bc04154f0e24a5

Contents?: true

Size: 1.03 KB

Versions: 9

Compression:

Stored size: 1.03 KB

Contents

module LightServiceExt
  class ApplicationOrchestrator < ApplicationOrganizer
    class << self
      def call(context, &each_organizer_result)
        orchestrator_ctx = process_each_organizer(ApplicationContext.make_with_defaults(context),
                                                  &each_organizer_result)
        with(orchestrator_ctx).around_each(RecordActions).reduce(all_steps)
      end

      def organizer_steps
        raise NotImplementedError
      end

      def process_each_organizer(orchestrator_ctx, &each_organizer_result)
        organizer_steps.each do |step_class|
          exec_method = exec_method_for(step_class)
          current_organizer_ctx = step_class.send(exec_method, orchestrator_ctx.input)
          yield(current_organizer_ctx, orchestrator_ctx: orchestrator_ctx) if each_organizer_result
        end
        orchestrator_ctx
      end

      private

      def exec_method_for(klass)
        return :call if klass.is_a?(LightService::Organizer) || klass.is_a?(Proc)

        :execute
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
light-service-ext-0.1.11 lib/light-service-ext/application_orchestrator.rb
light-service-ext-0.1.10 lib/light-service-ext/application_orchestrator.rb
light-service-ext-0.1.9 lib/light-service-ext/application_orchestrator.rb
light-service-ext-0.1.8 lib/light-service-ext/application_orchestrator.rb
light-service-ext-0.1.7 lib/light-service-ext/application_orchestrator.rb
light-service-ext-0.1.6 lib/light-service-ext/application_orchestrator.rb
light-service-ext-0.1.5 lib/light-service-ext/application_orchestrator.rb
light-service-ext-0.1.4 lib/light-service-ext/application_orchestrator.rb
light-service-ext-0.1.3 lib/light-service-ext/application_orchestrator.rb