Sha256: ab579802cea59a1bc0f3cabf237a48c2f6dfc43a55f4039ecb5bdf77f6f4dd7e

Contents?: true

Size: 770 Bytes

Versions: 8

Compression:

Stored size: 770 Bytes

Contents

require 'action_logic/action_includes'

module ActionLogic
  module ActionUseCase

    def self.included(klass)
      klass.extend ActionLogic::ActionIncludes
      klass.extend ClassMethods
    end

    module ClassMethods
      def execute(params = {})
        around(params) do |execution_context|
          raise ActionLogic::InvalidUseCaseError.new("ActionUseCase requires at least one ActionTask") if execution_context.tasks.empty?

          execution_context.call

          execution_context.tasks.reduce(execution_context.context) do |context, task|
            execution_context.context = task.execute(context)
            execution_context.context
          end
        end
      end

      def __private__type
        "use_case"
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
action_logic-0.3.3 lib/action_logic/action_use_case.rb
action_logic-0.3.2 lib/action_logic/action_use_case.rb
action_logic-0.3.1 lib/action_logic/action_use_case.rb
action_logic-0.3.0 lib/action_logic/action_use_case.rb
action_logic-0.2.8 lib/action_logic/action_use_case.rb
action_logic-0.2.7 lib/action_logic/action_use_case.rb
action_logic-0.2.6 lib/action_logic/action_use_case.rb
action_logic-0.2.5 lib/action_logic/action_use_case.rb