Class: Djwrapper::BackgroundProcess
- Inherits:
-
Object
- Object
- Djwrapper::BackgroundProcess
- Defined in:
- lib/djwrapper/background_process.rb
Direct Known Subclasses
Class Method Summary collapse
- .log(str, options = {}) ⇒ Object
-
.process!(params = {}) ⇒ Object
——————————————————–.
- .time ⇒ Object
- .verbose? ⇒ Boolean
Class Method Details
.log(str, options = {}) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/djwrapper/background_process.rb', line 62 def self.log(str, = {}) = [:debug] && !self.verbose? unless # +_+ # my_str = " [#{Time.now.utc}] #{str}" # +_+ # if defined?(Rails.logger) Rails.logger.info my_str else puts my_str end end end |
.process!(params = {}) ⇒ Object
56 57 58 59 60 |
# File 'lib/djwrapper/background_process.rb', line 56 def self.process!(params = {}) # Add code here that should be processed by every BackgroundProcess # right before it starts executing its own process! method. log("started.", :debug => true) end |
.time ⇒ Object
77 78 79 80 81 82 |
# File 'lib/djwrapper/background_process.rb', line 77 def self.time start = Time.now yield delta = Time.now - start log("Finished in #{delta} seconds.") end |
.verbose? ⇒ Boolean
84 85 86 |
# File 'lib/djwrapper/background_process.rb', line 84 def self.verbose? false end |