Class: ApplicationService
- Inherits:
-
Object
- Object
- ApplicationService
- Defined in:
- lib/generators/service/install/templates/services/application_service.rb
Class Attribute Summary collapse
-
.bm ⇒ Object
readonly
Returns the value of attribute bm.
-
.cmd ⇒ Object
readonly
Returns the value of attribute cmd.
-
.result ⇒ Object
readonly
Returns the value of attribute result.
-
.usecase ⇒ Object
readonly
Returns the value of attribute usecase.
Class Method Summary collapse
Class Attribute Details
.bm ⇒ Object (readonly)
Returns the value of attribute bm.
5 6 7 |
# File 'lib/generators/service/install/templates/services/application_service.rb', line 5 def bm @bm end |
.cmd ⇒ Object (readonly)
Returns the value of attribute cmd.
5 6 7 |
# File 'lib/generators/service/install/templates/services/application_service.rb', line 5 def cmd @cmd end |
.result ⇒ Object (readonly)
Returns the value of attribute result.
5 6 7 |
# File 'lib/generators/service/install/templates/services/application_service.rb', line 5 def result @result end |
.usecase ⇒ Object (readonly)
Returns the value of attribute usecase.
5 6 7 |
# File 'lib/generators/service/install/templates/services/application_service.rb', line 5 def usecase @usecase end |
Class Method Details
.call(cmd) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/generators/service/install/templates/services/application_service.rb', line 7 def call(cmd) @cmd = cmd @bm = Benchmark.measure do raise Errors::InvalidCommand if cmd.invalid? @usecase = usecase_class.new(cmd) raise Errors::NotAuthorizedError unless usecase.allowed? @result = ServiceResult.new { usecase.call } rollback if result.error.present? usecase.broadcast if result.ok? end log_command result rescue StandardError => e ServiceResult.new { raise e } end |
.rollback ⇒ Object
28 29 30 31 |
# File 'lib/generators/service/install/templates/services/application_service.rb', line 28 def rollback usecase.rollback_micros usecase.rollback end |