Class: Toolbox::WidgetList
- Inherits:
-
Object
- Object
- Toolbox::WidgetList
- Defined in:
- lib/toolbox/config.rb
Instance Attribute Summary collapse
-
#widgets ⇒ Object
readonly
Returns the value of attribute widgets.
Instance Method Summary collapse
-
#initialize(model_name, widgets, type) ⇒ WidgetList
constructor
A new instance of WidgetList.
Constructor Details
#initialize(model_name, widgets, type) ⇒ WidgetList
Returns a new instance of WidgetList.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/toolbox/config.rb', line 7 def initialize model_name, , type @widgets = [] last = nil h = nil .each do || h = { :name => last, :model_name => model_name} if .is_a? Hash raise 'Before an option hash there must be a widget name (string or symbol)' unless last raise 'The item before a option hash must be a string or a symbol' unless last.is_a?(String) || last.is_a?(Symbol) h.merge! end @widgets << type.new(h) if last && !last.is_a?(Hash) last = end # add the last field, if it's a symbol if last && !last.is_a?(Hash) h = { :name => last, :model_name => model_name} @widgets << type.new(h) end end |
Instance Attribute Details
#widgets ⇒ Object (readonly)
Returns the value of attribute widgets.
5 6 7 |
# File 'lib/toolbox/config.rb', line 5 def @widgets end |