Module: ShowFor::Attribute
- Included in:
- Builder
- Defined in:
- lib/show_for/attribute.rb
Instance Method Summary collapse
- #attribute(attribute_name, options = {}, &block) ⇒ Object
- #attributes(*attribute_names) ⇒ Object
- #value(attribute_name, options = {}, &block) ⇒ Object
Instance Method Details
#attribute(attribute_name, options = {}, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/show_for/attribute.rb', line 3 def attribute(attribute_name, ={}, &block) (attribute_name, ) block = block_from_value_option(attribute_name, ) unless block collection_block, block = block, nil if collection_block?(block) value = attribute_value(attribute_name, &block) wrap_label_and_content(attribute_name, value, , &collection_block) end |
#attributes(*attribute_names) ⇒ Object
22 23 24 25 26 |
# File 'lib/show_for/attribute.rb', line 22 def attributes(*attribute_names) attribute_names.map do |attribute_name| attribute(attribute_name) end.join.html_safe end |
#value(attribute_name, options = {}, &block) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/show_for/attribute.rb', line 13 def value(attribute_name, ={}, &block) (attribute_name, ) collection_block, block = block, nil if collection_block?(block) value = attribute_value(attribute_name, &block) wrap_content(attribute_name, value, , &collection_block) end |