Sha256: 4923b885ef24971bab464fb771601fc713ef28c53d306ff63ccb2bd36aaf2770

Contents?: true

Size: 745 Bytes

Versions: 3

Compression:

Stored size: 745 Bytes

Contents

# frozen_string_literal: true

module LightServiceExt
  class ApplicationOrganizer
    extend LightService::Organizer
    extend WithErrorHandler

    class << self
      def call(context)
        ctx = ApplicationContext.make_with_defaults(context)

        with_error_handler(ctx: ctx) do
          with(ctx).around_each(RecordActions).reduce(all_steps)
        end
      end

      def steps
        raise NotImplementedError
      end

      def reduce_if_success(steps)
        reduce_if(->(ctx) { ctx.success? && ctx[:errors].blank? }, steps)
      end

      private

      def all_steps
        return steps.push(AllActionsCompleteAction) if steps.is_a?(Array)

        [steps].push(AllActionsCompleteAction)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
light-service-ext-0.1.11 lib/light-service-ext/application_organizer.rb
light-service-ext-0.1.10 lib/light-service-ext/application_organizer.rb
light-service-ext-0.1.9 lib/light-service-ext/application_organizer.rb