Class: Formular::Attributes
- Inherits:
-
Hash
- Object
- Hash
- Formular::Attributes
- Defined in:
- lib/formular/attributes.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#to_html ⇒ Object
converts the hash into a string k1=v1 k2=v2 replaces underscores with - so we can use regular keys allows one layer of nested hashes so we can define data options as a hash.
Class Method Details
.[](hash) ⇒ Object
3 4 5 6 |
# File 'lib/formular/attributes.rb', line 3 def self.[](hash) hash ||= {} super end |
Instance Method Details
#to_html ⇒ Object
converts the hash into a string k1=v1 k2=v2 replaces underscores with - so we can use regular keys allows one layer of nested hashes so we can define data options as a hash.
11 12 13 14 15 16 17 18 19 |
# File 'lib/formular/attributes.rb', line 11 def to_html map { |key, value| if value.is_a?(Hash) value.map { |k,v| %(#{key_to_attr_name(key)}-#{attribute_html(k, v)}) }.join(' ') else attribute_html(key, value) end }.join(' ') end |