Class: Compendium::Query
- Inherits:
-
Object
- Object
- Compendium::Query
- Defined in:
- lib/compendium/query.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#metrics ⇒ Object
readonly
Returns the value of attribute metrics.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#proc ⇒ Object
Returns the value of attribute proc.
-
#report ⇒ Object
Returns the value of attribute report.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#through ⇒ Object
Returns the value of attribute through.
Instance Method Summary collapse
- #add_metric(name, proc, options = {}) ⇒ Object
-
#initialize(name, options, proc) ⇒ Query
constructor
A new instance of Query.
- #initialize_clone ⇒ Object
- #nil? ⇒ Boolean
- #ran? ⇒ Boolean (also: #has_run?)
- #render_chart(template, *options, &block) ⇒ Object
- #render_table(template, *options, &block) ⇒ Object
- #run(params, context = self) ⇒ Object
Constructor Details
Instance Attribute Details
#metrics ⇒ Object (readonly)
Returns the value of attribute metrics.
7 8 9 |
# File 'lib/compendium/query.rb', line 7 def metrics @metrics end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/compendium/query.rb', line 7 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/compendium/query.rb', line 8 def @options end |
#proc ⇒ Object
Returns the value of attribute proc.
8 9 10 |
# File 'lib/compendium/query.rb', line 8 def proc @proc end |
#report ⇒ Object
Returns the value of attribute report.
8 9 10 |
# File 'lib/compendium/query.rb', line 8 def report @report end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
7 8 9 |
# File 'lib/compendium/query.rb', line 7 def results @results end |
#through ⇒ Object
Returns the value of attribute through.
8 9 10 |
# File 'lib/compendium/query.rb', line 8 def through @through end |
Instance Method Details
#add_metric(name, proc, options = {}) ⇒ Object
29 30 31 |
# File 'lib/compendium/query.rb', line 29 def add_metric(name, proc, = {}) Compendium::Metric.new(name, self.name, proc, ).tap { |m| @metrics << m } end |
#initialize_clone ⇒ Object
17 18 19 20 |
# File 'lib/compendium/query.rb', line 17 def initialize_clone(*) super @metrics = @metrics.clone end |
#nil? ⇒ Boolean
46 47 48 |
# File 'lib/compendium/query.rb', line 46 def nil? proc.nil? end |
#ran? ⇒ Boolean Also known as: has_run?
41 42 43 |
# File 'lib/compendium/query.rb', line 41 def ran? !@results.nil? end |
#render_chart(template, *options, &block) ⇒ Object
37 38 39 |
# File 'lib/compendium/query.rb', line 37 def render_chart(template, *, &block) Compendium::Presenters::Chart.new(template, self, *, &block).render end |
#render_table(template, *options, &block) ⇒ Object
33 34 35 |
# File 'lib/compendium/query.rb', line 33 def render_table(template, *, &block) Compendium::Presenters::Table.new(template, self, *, &block).render end |
#run(params, context = self) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/compendium/query.rb', line 22 def run(params, context = self) collect_results(params, context) collect_metrics(context) @results end |