Module: Sidekiq::Util
Instance Method Summary collapse
- #constantize(camel_cased_word) ⇒ Object
- #err(msg) ⇒ Object
- #log(msg) ⇒ Object
- #verbose(msg) ⇒ Object
- #watchdog(last_words) ⇒ Object
Instance Method Details
#constantize(camel_cased_word) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/sidekiq/util.rb', line 4 def constantize(camel_cased_word) names = camel_cased_word.split('::') names.shift if names.empty? || names.first.empty? constant = Object names.each do |name| constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name) end constant end |
#err(msg) ⇒ Object
23 24 25 |
# File 'lib/sidekiq/util.rb', line 23 def err(msg) STDERR.puts(msg) end |
#log(msg) ⇒ Object
27 28 29 |
# File 'lib/sidekiq/util.rb', line 27 def log(msg) STDOUT.puts(msg) unless $TESTING end |
#verbose(msg) ⇒ Object
31 32 33 |
# File 'lib/sidekiq/util.rb', line 31 def verbose(msg) STDOUT.puts(msg) if $DEBUG end |
#watchdog(last_words) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/sidekiq/util.rb', line 15 def watchdog(last_words) yield rescue => ex STDERR.puts last_words STDERR.puts ex STDERR.puts ex.backtrace.join("\n") end |