Class: Assistant::Service
Overview
Base class for the Assistant gem
Class Method Summary
collapse
Instance Method Summary
collapse
input, input_checker_meth, input_getter_meth, input_require_conditional_meth, input_require_validator_meth, input_type_validator_meth
Methods included from LogList
#add_log, #log_item_error_initialize, #merge_logs
Constructor Details
#initialize(**args) ⇒ Service
Returns a new instance of Service.
19
20
21
22
|
# File 'lib/assistant/service.rb', line 19
def initialize(**args)
@inputs = args
@logs = []
end
|
Class Method Details
.run ⇒ Object
14
15
16
|
# File 'lib/assistant/service.rb', line 14
def run(**)
new(**).run
end
|
Instance Method Details
#failure? ⇒ Boolean
43
44
45
|
# File 'lib/assistant/service.rb', line 43
def failure?
errors.any?
end
|
#result ⇒ Object
35
36
37
|
# File 'lib/assistant/service.rb', line 35
def result
@result ||= execute
end
|
#run ⇒ Object
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/assistant/service.rb', line 24
def run
validate_inputs
validate
if errors.empty?
{ result:, status:, warnings: }
else
{ errors:, result: nil, status: :with_errors }
end
end
|
#status ⇒ Object
47
48
49
|
# File 'lib/assistant/service.rb', line 47
def status
warnings.empty? ? :ok : :with_warnings
end
|
#success? ⇒ Boolean
39
40
41
|
# File 'lib/assistant/service.rb', line 39
def success?
errors.empty?
end
|