Sha256: 8022e819647c89fc7eee800522454ab66287d385374bde31b7a9c486b418e563

Contents?: true

Size: 764 Bytes

Versions: 3

Compression:

Stored size: 764 Bytes

Contents

require 'action_logic/action_core'
require 'action_logic/action_validation'

module ActionLogic
  module ActionUseCase
    include ActionLogic::ActionValidation
    include ActionLogic::ActionCore

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

    module ClassMethods
      def execute(params = {})
        around(params) do |execution_context|
          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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
action_logic-0.0.6 lib/action_logic/action_use_case.rb
action_logic-0.0.5 lib/action_logic/action_use_case.rb
action_logic-0.0.4 lib/action_logic/action_use_case.rb