Class: Roda::Component::Form::Attributes
- Inherits:
-
Object
- Object
- Roda::Component::Form::Attributes
- Defined in:
- lib/roda/component/form.rb
Instance Method Summary collapse
- #_attributes ⇒ Object
- #empty? ⇒ Boolean
- #set_attr_accessors(attrs) ⇒ Object
- #set_values(atts) ⇒ Object
Instance Method Details
#_attributes ⇒ Object
33 34 35 |
# File 'lib/roda/component/form.rb', line 33 def _attributes @_attributes ||= [] end |
#empty? ⇒ Boolean
37 38 39 |
# File 'lib/roda/component/form.rb', line 37 def empty? _attributes.empty? end |
#set_attr_accessors(attrs) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/roda/component/form.rb', line 20 def set_attr_accessors attrs attrs.each do |attr| define_singleton_method "#{attr}=" do |value| value = value.to_obj if value.is_a? Hash instance_variable_set(:"@#{attr}", value) end define_singleton_method attr do instance_variable_get(:"@#{attr}") end end end |
#set_values(atts) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/roda/component/form.rb', line 9 def set_values(atts) @_attributes = [] atts.each do |key, val| if respond_to?("#{key}=") send(:"#{key}=", val) @_attributes << key end end end |