Class: Coiasira::Base
- Inherits:
-
Object
- Object
- Coiasira::Base
- Defined in:
- lib/coiasira/base.rb
Constant Summary collapse
- @@logger =
nil
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #logger ⇒ Object
-
#process(context) ⇒ Object
def logger merged.logger || self.class.logger end.
Constructor Details
#initialize ⇒ Base
31 32 33 |
# File 'lib/coiasira/base.rb', line 31 def initialize() @action = self.class.default_action end |
Class Method Details
.default_action ⇒ Object
26 27 28 |
# File 'lib/coiasira/base.rb', line 26 def default_action 'default' end |
.logger ⇒ Object
9 10 11 |
# File 'lib/coiasira/base.rb', line 9 def self.logger @@logger end |
.logger=(obj) ⇒ Object
13 14 15 |
# File 'lib/coiasira/base.rb', line 13 def self.logger=(obj) @@logger = obj end |
.process(context) ⇒ Object
22 23 24 |
# File 'lib/coiasira/base.rb', line 22 def process(context) new.process(context) end |
Instance Method Details
#logger ⇒ Object
17 18 19 |
# File 'lib/coiasira/base.rb', line 17 def logger @@logger end |
#process(context) ⇒ Object
def logger
merged.logger || self.class.logger
end
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/coiasira/base.rb', line 39 def process(context) @action = context.action if context && context.respond_to?(:action) && context.action logger.info("Starting job #{self.class.name.underscore} with action #{@action}") begin self.__send__(@action, context) logger.info("Finished job #{self.class.name.underscore} with action #{@action}") rescue logger.info("Failed job #{self.class.name.underscore} with action #{@action}") raise end end |