Class: Dashboards::Summary
- Inherits:
-
Object
- Object
- Dashboards::Summary
- Defined in:
- lib/dashboards/dsl/summary.rb
Constant Summary collapse
- DEFAULT_PERIODS =
[ { name: '24h', duration: 24.hours }, { name: '7d', duration: 7.days }, { name: '30d', duration: 30.days } ]
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 = {}) ⇒ Summary
constructor
A new instance of Summary.
- #render(context) ⇒ Object
Constructor Details
#initialize(data_or_options, options = {}) ⇒ Summary
Returns a new instance of Summary.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/dashboards/dsl/summary.rb', line 13 def initialize(, = {}) if .is_a?(Hash) @data = [:data] @options = .except(:data) else @data = @options = end @periods = @options[:periods] || DEFAULT_PERIODS end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/dashboards/dsl/summary.rb', line 5 def data @data end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/dashboards/dsl/summary.rb', line 5 def @options end |
Instance Method Details
#render(context) ⇒ Object
24 25 26 27 |
# File 'lib/dashboards/dsl/summary.rb', line 24 def render(context) data = @data.is_a?(Proc) ? context.instance_exec(&@data) : @data render_summary(data, context) end |