Class: JBackground::Task
- Inherits:
-
Object
- Object
- JBackground::Task
- Defined in:
- lib/j_background/task.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
- #execute_task ⇒ Object
-
#initialize ⇒ Task
constructor
A new instance of Task.
- #run ⇒ Object
Constructor Details
#initialize ⇒ Task
Returns a new instance of Task.
7 8 9 |
# File 'lib/j_background/task.rb', line 7 def initialize self.logger = JBackground::Base.logger end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/j_background/task.rb', line 5 def logger @logger end |
Instance Method Details
#execute_task ⇒ Object
21 22 23 |
# File 'lib/j_background/task.rb', line 21 def execute_task puts "You have not defined a task" end |
#run ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/j_background/task.rb', line 11 def run logger.debug "Background Thread #{Thread.current.object_id} - Executing task: #{self.class.name} #{Time.now}" begin execute_task rescue => e logger.error "Background Thread #{Thread.current.object_id} - Error executing task: #{self.class.name} #{e}:\n#{e.backtrace.join('\n')}" end logger.debug "Background Thread #{Thread.current.object_id} - Finished task: #{self.class.name} #{Time.now}" end |