module Fastbeans
Constants
- VERSION
Attributes
debug_mode[RW]
Debug mode
Public Class Methods
benchmark(str, &blk)
click to toggle source
# File lib/fastbeans.rb, line 28 def benchmark(str, &blk) debug(str) t1 = Time.now blk.call ensure t2 = Time.now debug("Time spent: #{t2-t1}s") if t1 end
debug(str_or_exc)
click to toggle source
# File lib/fastbeans.rb, line 10 def debug(str_or_exc) case str_or_exc when String STDERR.puts("[#{Time.now}] #{str_or_exc}") if self.debug_mode when Exception debug("Exception: #{str_or_exc.message}\n#{str_or_exc.backtrace.join("\n")}") end end
error(str_or_exc)
click to toggle source
# File lib/fastbeans.rb, line 19 def error(str_or_exc) case str_or_exc when String STDERR.puts("[#{Time.now}] #{str_or_exc}") when Exception error("Exception: #{str_or_exc.message}\n#{str_or_exc.backtrace.join("\n")}") end end
exception(classname)
click to toggle source
# File lib/fastbeans.rb, line 37 def exception(classname) begin Fastbeans.const_get(classname.to_s) rescue NameError Fastbeans.const_set(classname.to_s, Class.new(Fastbeans::AutogeneratedException)) end end