Class: ActsAsDashboard::Config
- Inherits:
-
Object
- Object
- ActsAsDashboard::Config
- Defined in:
- lib/acts_as_dashboard/config.rb
Instance Attribute Summary collapse
-
#widgets ⇒ Object
readonly
Returns the value of attribute widgets.
Instance Method Summary collapse
- #add_widget(widget) ⇒ Object
- #find_widget(name) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
5 6 7 |
# File 'lib/acts_as_dashboard/config.rb', line 5 def initialize = [] end |
Instance Attribute Details
#widgets ⇒ Object (readonly)
Returns the value of attribute widgets.
3 4 5 |
# File 'lib/acts_as_dashboard/config.rb', line 3 def end |
Instance Method Details
#add_widget(widget) ⇒ Object
9 10 11 12 |
# File 'lib/acts_as_dashboard/config.rb', line 9 def () raise ArgumentError, 'The "widget" argument must be an ActsAsDashboard::Widget.' unless .is_a? ActsAsDashboard::Widget .push end |
#find_widget(name) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/acts_as_dashboard/config.rb', line 14 def (name) raise ArgumentError, 'The "name" argument must respond to #to_sym .' unless name.respond_to? :to_sym # We specifically use #find_all here so that we can grab the last widget with that name. # This allows users to define multiple widgets with the same name, and have only the last # be used. .find_all {|w| w.name == name.to_sym}.last end |