Class: Facio::Service

Inherits:
ActiveJob::Base
  • Object
show all
Includes:
Callbacks, Execution, ServiceContext, ServiceResult, Transactional, Translations
Defined in:
lib/facio/service.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Execution

#facio_perform_with_arguments

Class Method Details

.performObject 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

Returns:

  • (Boolean)


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)

Returns:

  • (Boolean)


41
42
43
# File 'lib/facio/service.rb', line 41

def performed?
  @performed
end

#resultObject

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

Returns:

  • (Boolean)


46
47
48
49
50
# File 'lib/facio/service.rb', line 46

def success?
  success = performed? && valid?
  success &&= @result.valid? if @result
  success
end