Class: SimpleModelView::CollectionTableHeaderBuilder
- Inherits:
-
Object
- Object
- SimpleModelView::CollectionTableHeaderBuilder
- Includes:
- TemplateHelpers
- Defined in:
- lib/simple_model_view/collection_table_header_builder.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #actions(*_args, **options) ⇒ Object
- #column(attr_name, *_args, **options) ⇒ Object
-
#initialize(template, collection) ⇒ CollectionTableHeaderBuilder
constructor
A new instance of CollectionTableHeaderBuilder.
Methods included from TemplateHelpers
#blank_span, #block_concat, #merge_html_attrs
Constructor Details
#initialize(template, collection) ⇒ CollectionTableHeaderBuilder
Returns a new instance of CollectionTableHeaderBuilder.
9 10 11 12 |
# File 'lib/simple_model_view/collection_table_header_builder.rb', line 9 def initialize(template, collection) @template = template @collection = collection end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
7 8 9 |
# File 'lib/simple_model_view/collection_table_header_builder.rb', line 7 def collection @collection end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
7 8 9 |
# File 'lib/simple_model_view/collection_table_header_builder.rb', line 7 def template @template end |
Instance Method Details
#actions(*_args, **options) ⇒ Object
24 25 26 27 |
# File 'lib/simple_model_view/collection_table_header_builder.rb', line 24 def actions(*_args, **) th_html_attributes = merge_html_attrs default_header_html, [:header_html].to_h template.content_tag :th, [:title].to_s, **th_html_attributes end |
#column(attr_name, *_args, **options) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/simple_model_view/collection_table_header_builder.rb', line 14 def column(attr_name, *_args, **) title = [:title] title ||= if collection_class collection_class.human_attribute_name attr_name else attr_name.to_s.humanize end template.content_tag :th, title, [:header_html] || {} end |