Class: Resol::Service
Defined Under Namespace
Classes: Failure, InvalidCommandCall, InvalidCommandImplementation, Result
Class Method Summary
collapse
Methods included from Callbacks
included
Methods included from Builder
included
Class Method Details
.call(*args, **kwargs, &block) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/resol/service.rb', line 42
def call(*args, **kwargs, &block)
service = build(*args, **kwargs)
result = return_engine.wrap_call(service) do
service.instance_variable_set(:@__performing__, true)
__run_callbacks__(service)
service.call(&block)
end
if return_engine.uncaught_call?(result)
error_message = "No `#success!` or `#fail!` called in `#call` method in #{service.class}."
raise InvalidCommandImplementation, error_message
else
Resol::Success(result.data)
end
rescue self::Failure => e
Resol::Failure(e)
end
|
.call! ⇒ Object
65
66
67
|
# File 'lib/resol/service.rb', line 65
def call!(...)
call(...).value_or { |error| raise error }
end
|
.inherited(klass) ⇒ Object
37
38
39
40
|
# File 'lib/resol/service.rb', line 37
def inherited(klass)
klass.const_set(:Failure, Class.new(klass::Failure))
super
end
|
.return_engine ⇒ Object
61
62
63
|
# File 'lib/resol/service.rb', line 61
def return_engine
Resol::Configuration.return_engine
end
|