Class: SimpleModelView::CollectionTableHeaderBuilder

Inherits:
Object
  • Object
show all
Includes:
TemplateHelpers
Defined in:
lib/simple_model_view/collection_table_header_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#collectionObject (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

#templateObject (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, **options)
  th_html_attributes = merge_html_attrs default_header_html, options[:header_html].to_h
  template. :th, options[: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, **options)
  title = options[:title]
  title ||= if collection_class
              collection_class.human_attribute_name attr_name
            else
              attr_name.to_s.humanize
            end
  template. :th, title, options[:header_html] || {}
end