Class: Djwrapper::BackgroundProcess

Inherits:
Object
  • Object
show all
Defined in:
lib/djwrapper/background_process.rb

Direct Known Subclasses

DelayedBackgroundProcess

Class Method Summary collapse

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, options = {})
  _hide_message = options[:debug] && !self.verbose?

  unless _hide_message
    # +_+ #
    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

.timeObject



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

Returns:

  • (Boolean)


84
85
86
# File 'lib/djwrapper/background_process.rb', line 84

def self.verbose?
  false
end