Class: StringRenderer
- Inherits:
-
ResourceRenderer::AttributeRenderer::Base
- Object
- ResourceRenderer::AttributeRenderer::Base
- StringRenderer
- Defined in:
- app/attribute_renderers/string_renderer.rb
Instance Attribute Summary
Attributes inherited from ResourceRenderer::AttributeRenderer::Base
Instance Method Summary collapse
Methods inherited from ResourceRenderer::AttributeRenderer::Base
Constructor Details
This class inherits a constructor from ResourceRenderer::AttributeRenderer::Base
Instance Method Details
#display(attribute_name, label, options = {}, &block) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/attribute_renderers/string_renderer.rb', line 2 def display(attribute_name, label, = {}, &block) return h.capture { block.call(resource) } if block_given? .reverse_merge!(class: nil) html_class = .delete(:class) html_attributes = { class: html_class } value = value_for_attribute(attribute_name) value = value.to_s unless value.is_a?(String) helper.capture do h.content_tag(:div, html_attributes) { value } end end |