Module: ActionLogic::ActionUseCase::ClassMethods

Defined in:
lib/action_logic/action_use_case.rb

Instance Method Summary collapse

Instance Method Details

#__private__typeObject



25
26
27
# File 'lib/action_logic/action_use_case.rb', line 25

def __private__type
  "use_case"
end

#execute(params = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/action_logic/action_use_case.rb', line 12

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