Class: SqlPatches
- Inherits:
-
Object
- Object
- SqlPatches
- Defined in:
- lib/patches/sql_patches.rb
Class Method Summary collapse
- .class_exists?(name) ⇒ Boolean
- .elapsed_time(start_time) ⇒ Object
- .module_exists?(name) ⇒ Boolean
- .patched=(val) ⇒ Object
- .patched? ⇒ Boolean
- .record_sql(statement, &block) ⇒ Object
- .should_measure? ⇒ Boolean
Class Method Details
.class_exists?(name) ⇒ Boolean
11 12 13 14 15 |
# File 'lib/patches/sql_patches.rb', line 11 def self.class_exists?(name) eval(name + ".class").to_s.eql?('Class') rescue NameError false end |
.elapsed_time(start_time) ⇒ Object
35 36 37 |
# File 'lib/patches/sql_patches.rb', line 35 def self.elapsed_time(start_time) ((Time.now - start_time).to_f * 1000).round(1) end |
.module_exists?(name) ⇒ Boolean
17 18 19 20 21 |
# File 'lib/patches/sql_patches.rb', line 17 def self.module_exists?(name) eval(name + ".class").to_s.eql?('Module') rescue NameError false end |
.patched=(val) ⇒ Object
7 8 9 |
# File 'lib/patches/sql_patches.rb', line 7 def self.patched=(val) @patched = val end |
.patched? ⇒ Boolean
3 4 5 |
# File 'lib/patches/sql_patches.rb', line 3 def self.patched? @patched end |
.record_sql(statement, &block) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/patches/sql_patches.rb', line 23 def self.record_sql(statement, &block) start = Time.now result = yield record = ::Rack::MiniProfiler.record_sql( statement, elapsed_time(start) ) return result, record end |
.should_measure? ⇒ Boolean
30 31 32 33 |
# File 'lib/patches/sql_patches.rb', line 30 def self.should_measure? current = ::Rack::MiniProfiler.current (current && current.measure) end |