Method: SimpleService::InstanceMethods#call

Defined in:
lib/simple_service.rb

#call(kwargs) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/simple_service.rb', line 52

def call(kwargs)
  result.value = kwargs.is_a?(Result) ? kwargs.value : kwargs

  commands.each do |command|
    @current_command = command

    command_output = if command.is_a?(Class)
      command.new.call(result.value)
    elsif command.is_a?(Symbol)
      method(command).call(result.value)
    end

    if command_output.is_a?(Result)
      result.append_result(command_output)
    end

    break if result.failure?
  end

  result
end