Class: Rack::Bug::MongoPanel
- Defined in:
- lib/rack/bug/panels/mongo_panel.rb,
lib/rack/bug/panels/mongo_panel/stats.rb
Defined Under Namespace
Classes: Stats
Instance Attribute Summary
Attributes inherited from Panel
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Panel
#after, #before, #call, #has_content?, #initialize, #panel_app, #render
Methods included from Render
#compile, #compile!, #compiled_source, #method_name, #method_name_without_locals, #render_template, #signed_params
Constructor Details
This class inherits a constructor from Rack::Bug::Panel
Class Method Details
.record(command, &block) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/rack/bug/panels/mongo_panel.rb', line 9 def self.record(command, &block) return block.call unless Rack::Bug.enabled? start_time = Time.now result = block.call total_time = Time.now - start_time stats.record_call(total_time * 1_000, command) return result end |
Instance Method Details
#content ⇒ Object
35 36 37 38 39 |
# File 'lib/rack/bug/panels/mongo_panel.rb', line 35 def content result = render_template "panels/mongo", :stats => self.class.stats self.class.reset return result end |
#heading ⇒ Object
31 32 33 |
# File 'lib/rack/bug/panels/mongo_panel.rb', line 31 def heading "Mongo: %.2fms (#{self.class.stats.queries.size} calls)" % self.class.stats.time end |
#name ⇒ Object
27 28 29 |
# File 'lib/rack/bug/panels/mongo_panel.rb', line 27 def name "mongo" end |