Method: SimpleService::ClassMethods#call

Defined in:
lib/simple_service.rb

#call(kwargs = {}) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/simple_service.rb', line 32

def call(kwargs={})
  service = self.new

  # if kwargs is a result obj then pull its hash out via #value
  service.result.value = kwargs.is_a?(Result) ? kwargs.value : kwargs

  get_commands(service).each do |cmnd|
    service = execute_command(cmnd, service)
    break if service.result.failure?
  end

  service.result
end