Class: Facio::Service
- Inherits:
-
ActiveJob::Base
- Object
- ActiveJob::Base
- Facio::Service
- Includes:
- Callbacks, Execution, ServiceContext, ServiceResult, Transactional, Translations
- Defined in:
- lib/facio/service.rb
Class Method Summary collapse
- .perform ⇒ Object (also: perform_now)
Instance Method Summary collapse
-
#failed? ⇒ Boolean
Returns whether the service failed to perform.
-
#performed? ⇒ Boolean
Returns whether the service has been performed (only when using perform).
-
#result ⇒ Object
Returns the result, be it the result object or the context object.
-
#success? ⇒ Boolean
Returns whether the service was successfully performed.
Methods included from Execution
Class Method Details
.perform ⇒ Object Also known as: perform_now
18 19 20 21 22 |
# File 'lib/facio/service.rb', line 18 def perform(...) job = job_or_instantiate(...) job.perform_now job end |
Instance Method Details
#failed? ⇒ Boolean
Returns whether the service failed to perform
53 54 55 |
# File 'lib/facio/service.rb', line 53 def failed? !success? end |
#performed? ⇒ Boolean
Returns whether the service has been performed (only when using perform)
41 42 43 |
# File 'lib/facio/service.rb', line 41 def performed? @performed end |
#result ⇒ Object
Returns the result, be it the result object or the context object
28 29 30 |
# File 'lib/facio/service.rb', line 28 def result @result || context.result end |
#success? ⇒ Boolean
Returns whether the service was successfully performed
46 47 48 49 50 |
# File 'lib/facio/service.rb', line 46 def success? success = performed? && valid? success &&= @result.valid? if @result success end |