Class: ServiceBase
- Inherits:
-
Object
- Object
- ServiceBase
- Defined in:
- lib/generators/service/templates/base/service_base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#cmd ⇒ Object
readonly
Returns the value of attribute cmd.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(command) ⇒ ServiceBase
constructor
A new instance of ServiceBase.
Constructor Details
#initialize(command) ⇒ ServiceBase
Returns a new instance of ServiceBase.
6 7 8 |
# File 'lib/generators/service/templates/base/service_base.rb', line 6 def initialize(command) @cmd = command end |
Instance Attribute Details
#cmd ⇒ Object (readonly)
Returns the value of attribute cmd.
4 5 6 |
# File 'lib/generators/service/templates/base/service_base.rb', line 4 def cmd @cmd end |
Class Method Details
.call(command) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/generators/service/templates/base/service_base.rb', line 10 def self.call(command) raise Errors::InvalidCommand, command.class if command.invalid? obj = new(command) obj.call rescue StandardError => e error(e) obj.send(:rollback) raise e end |
.error(err) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/generators/service/templates/base/service_base.rb', line 23 def self.error(err) # don't log custom errors if you want :D return if err.class.name.start_with?(self.class.name.split('::').first) # # Add your logging logic # ex: # Rollbar.error(err) # end |