Module: ServiceActor::Core::ClassMethods

Defined in:
lib/service_actor/core.rb

Instance Method Summary collapse

Instance Method Details

#call(result = nil, **arguments) ⇒ Object

Call an actor with a given result. Returns the result.

CreateUser.call(name: "Joe")


14
15
16
17
18
19
20
21
# File 'lib/service_actor/core.rb', line 14

def call(result = nil, **arguments)
  result = ServiceActor::Result.to_result(result).merge!(arguments)

  instance = new(result)
  instance._call

  result
end

#result(result = nil, **arguments) ⇒ Object

Call an actor with arguments. Returns the result and does not raise on failure.

CreateUser.result(name: "Joe")


27
28
29
30
31
# File 'lib/service_actor/core.rb', line 27

def result(result = nil, **arguments)
  call(result, **arguments)
rescue failure_class => e
  e.result
end