Sha256: 4a2c16001e67f6b9978b213de3433d42d0357154c64e4a1a1262347625365664
Contents?: true
Size: 965 Bytes
Versions: 2
Compression:
Stored size: 965 Bytes
Contents
class Remnant class Database module ClassMethods def disable! @enabled = false end def enable! @enabled = true end def enabled? @enabled end def unsuppress! @suppress = false end def suppress? @suppress || true end def record(sql, backtrace = [], &block) return block.call unless Remnant::Database.enabled? start_time = Time.now result = block.call queries << Remnant::Database::Query.new(sql, Time.now - start_time, backtrace) return result end def reset @suppress = true Thread.current['remnant.database.queries'] = [] end def queries Thread.current['remnant.database.queries'] ||= [] end def total_time @total_time ||= (queries.inject(0) {|memo, query| memo + query.time}) * 1000 end end extend ClassMethods end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
remnant-0.3.1 | lib/remnant/database.rb |
remnant-0.3.0 | lib/remnant/database.rb |