Module: Pg_explain
- Defined in:
- lib/pg_explain.rb
Overview
This module contains:
-
Activation/disactivation methods
-
Configuration methods
-
Output formatting methods
Constant Summary collapse
- @@color =
false
- @@analyze =
false
- @@enable =
false
Class Method Summary collapse
-
.configure(options = {}) ⇒ Object
To setup the configuration options.
-
.disable ⇒ Object
Disables the plugin.
-
.enable ⇒ Object
Activates the plugin.
-
.enabled? ⇒ Boolean
Check if the plugin is enabled.
-
.format(message) ⇒ Object
Formats the results of the explain query.
-
.method ⇒ Object
Returns “Explain” or “Explain Analyze”.
Class Method Details
.configure(options = {}) ⇒ Object
To setup the configuration options
29 30 31 32 |
# File 'lib/pg_explain.rb', line 29 def self.configure( = {}) @@color ||= [:color] @@analyze ||= [:analyze] end |
.disable ⇒ Object
Disables the plugin
19 20 21 |
# File 'lib/pg_explain.rb', line 19 def self.disable @@enable = false end |
.enable ⇒ Object
Activates the plugin
14 15 16 |
# File 'lib/pg_explain.rb', line 14 def self.enable @@enable = true end |
.enabled? ⇒ Boolean
Check if the plugin is enabled
24 25 26 |
# File 'lib/pg_explain.rb', line 24 def self.enabled? @@enable end |
.format(message) ⇒ Object
Formats the results of the explain query
40 41 42 43 |
# File 'lib/pg_explain.rb', line 40 def self.format() = "\n" + .collect { |line| " " + colorize(line["QUERY PLAN"]) }.join("\n") + "\n" color ? "\033[01;30m#{}\033[00m" : end |
.method ⇒ Object
Returns “Explain” or “Explain Analyze”
35 36 37 |
# File 'lib/pg_explain.rb', line 35 def self.method ("Explain Analyze" if analyze) || "Explain" end |