Class: CC::Service::Invocation::WithReturnValues

Inherits:
Object
  • Object
show all
Defined in:
lib/cc/service/invocation/with_return_values.rb

Instance Method Summary collapse

Constructor Details

#initialize(invocation, message = nil) ⇒ WithReturnValues

Returns a new instance of WithReturnValues.



3
4
5
6
# File 'lib/cc/service/invocation/with_return_values.rb', line 3

def initialize(invocation, message = nil)
  @invocation = invocation
  @message = message || "An internal error happened"
end

Instance Method Details

#callObject



8
9
10
11
12
13
14
15
# File 'lib/cc/service/invocation/with_return_values.rb', line 8

def call
  result = @invocation.call
  if result.nil?
    { ok: false, message: @message }
  else
    result
  end
end