Class: Dashboards::ChangeOverPeriod
- Inherits:
-
Object
- Object
- Dashboards::ChangeOverPeriod
- Defined in:
- lib/dashboards/dsl/change_over_period.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(data_or_options, options = {}) ⇒ ChangeOverPeriod
constructor
A new instance of ChangeOverPeriod.
- #render(context) ⇒ Object
Constructor Details
#initialize(data_or_options, options = {}) ⇒ ChangeOverPeriod
Returns a new instance of ChangeOverPeriod.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/dashboards/dsl/change_over_period.rb', line 7 def initialize(, = {}) if .is_a?(Hash) @data = [:data] @options = .except(:data) else @data = @options = end @period = @options[:period] || 7.days @date_column = @options[:date_column] || :created_at end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/dashboards/dsl/change_over_period.rb', line 5 def data @data end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/dashboards/dsl/change_over_period.rb', line 5 def @options end |
Instance Method Details
#render(context) ⇒ Object
19 20 21 22 |
# File 'lib/dashboards/dsl/change_over_period.rb', line 19 def render(context) data = @data.is_a?(Proc) ? context.instance_exec(&@data) : @data render_change(data, context) end |