Class: CommandTower::ServiceBase
Direct Known Subclasses
AdminService::Users, Authorize::Validate, InboxService::Blast::Delete, InboxService::Blast::Metadata, InboxService::Blast::NewUserBlaster, InboxService::Blast::Retrieve, InboxService::Blast::Upsert, InboxService::Message::Metadata, InboxService::Message::Modify, InboxService::Message::Retrieve, InboxService::Message::Send, Jwt::AuthenticateUser, Jwt::Decode, Jwt::Encode, Jwt::LoginCreate, Jwt::TimeDelayToken, LoginStrategy::PlainText::Create, LoginStrategy::PlainText::EmailVerification::Generate, LoginStrategy::PlainText::EmailVerification::Required, LoginStrategy::PlainText::EmailVerification::Send, LoginStrategy::PlainText::EmailVerification::Verify, LoginStrategy::PlainText::Login, CommandTower::Secrets::Cleanse, CommandTower::Secrets::Generate, CommandTower::Secrets::Verify, UserAttributes::Modify, UserAttributes::Roles, Username::Available
Defined Under Namespace
Classes: ArgumentValidationError, CompositionValidationError, ConfigurationError, DefaultValueError, KeyValidationError, NameConflictError, NestedOneOfError, OneOfError, ServiceBaseError, ValidationError
Constant Summary
collapse
- ON_ARGUMENT_VALIDATION =
[
DEFAULT_VALIDATION = :raise,
:fail_early,
:log,
]
Class Method Summary
collapse
Instance Method Summary
collapse
included
#aletered_message, #class_name, #log, #log_error, #log_info, #log_prefix, #log_warn, #logger, #service_id
Class Method Details
.inherited(subclass) ⇒ Object
29
30
31
32
33
34
35
|
# File 'app/services/command_tower/service_base.rb', line 29
def self.inherited(subclass)
subclass.around(:service_base_logging)
subclass.around(:internal_validate)
subclass.after(:sanitize_params)
end
|
Instance Method Details
#internal_validate(interactor) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'app/services/command_tower/service_base.rb', line 41
def internal_validate(interactor)
begin
validate! run_validations! rescue StandardError => e
log_error("Error during validation. #{e.message}")
raise
end
interactor.call
end
|
#service_base_logging(interactor) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'app/services/command_tower/service_base.rb', line 55
def service_base_logging(interactor)
beginning_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
log_info("Start")
interactor.call
status = :complete
rescue ::Interactor::Failure
status = :failure
raise
rescue ::Exception => e
status = :error
log_error("Error #{e.class.name}")
raise
ensure
finished_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
elapsed = ((finished_time - beginning_time) * 1000).round(2)
log_info("Finished with [#{status}]...elapsed #{elapsed}ms")
end
|
#validate! ⇒ Object
37
38
39
|
# File 'app/services/command_tower/service_base.rb', line 37
def validate!
end
|