Class: Compendium::Presenters::Chart
- Defined in:
- app/classes/compendium/presenters/chart.rb
Instance Attribute Summary collapse
-
#chart_provider ⇒ Object
readonly
Returns the value of attribute chart_provider.
-
#container ⇒ Object
readonly
Returns the value of attribute container.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#options ⇒ Object
Returns the value of attribute options.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Attributes inherited from Query
#filters, #metrics, #name, #proc, #report, #results
Instance Method Summary collapse
-
#initialize(template, object, *args, &setup) ⇒ Chart
constructor
A new instance of Chart.
- #render ⇒ Object
Methods inherited from Query
#add_filter, #add_metric, #chart, #empty?, #initialize_clone, #nil?, #ran?, #render_chart, #render_table, #run, #url
Constructor Details
#initialize(template, object, *args, &setup) ⇒ Chart
Returns a new instance of Chart.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/classes/compendium/presenters/chart.rb', line 9 def initialize(template, object, *args, &setup) super(template, object) self. = args. type, container = args if remote? # If the query hasn't run yet, render a chart that loads its data remotely (ie. through AJAX) # ie. if rendering a query from a report class directly @data = query.url @params = collect_params else @data = [:index] ? results.records[[:index]] : results @data = @data.records if @data.is_a?(Compendium::ResultSet) @data = @data[0...-1] if query.[:totals] end @container = container || query.name initialize_chart_provider(type, &setup) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (private)
74 75 76 77 |
# File 'app/classes/compendium/presenters/chart.rb', line 74 def method_missing(name, *args, &block) return chart_provider.send(name, *args, &block) if chart_provider.respond_to?(name) super end |
Instance Attribute Details
#chart_provider ⇒ Object (readonly)
Returns the value of attribute chart_provider.
6 7 8 |
# File 'app/classes/compendium/presenters/chart.rb', line 6 def chart_provider @chart_provider end |
#container ⇒ Object (readonly)
Returns the value of attribute container.
6 7 8 |
# File 'app/classes/compendium/presenters/chart.rb', line 6 def container @container end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'app/classes/compendium/presenters/chart.rb', line 6 def data @data end |
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'app/classes/compendium/presenters/chart.rb', line 7 def @options end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
6 7 8 |
# File 'app/classes/compendium/presenters/chart.rb', line 6 def params @params end |
Instance Method Details
#render ⇒ Object
31 32 33 |
# File 'app/classes/compendium/presenters/chart.rb', line 31 def render chart_provider.render(@template, @container) end |