Class: SortableBy::TableHeader
- Inherits:
-
Object
- Object
- SortableBy::TableHeader
- Defined in:
- lib/sortable_by/table_header.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#header_html ⇒ Object
Returns the value of attribute header_html.
Instance Method Summary collapse
- #capture(block) ⇒ Object
- #header(attribute, label: nil) ⇒ Object
-
#initialize(path_helper:, context:, icon:, model: nil, params: {}) ⇒ TableHeader
constructor
A new instance of TableHeader.
- #sortable(attribute, label: nil) ⇒ Object
- #to_html ⇒ Object
- #to_row ⇒ Object
Constructor Details
#initialize(path_helper:, context:, icon:, model: nil, params: {}) ⇒ TableHeader
Returns a new instance of TableHeader.
11 12 13 14 15 16 17 |
# File 'lib/sortable_by/table_header.rb', line 11 def initialize(path_helper:, context:, icon:, model: nil, params: {}) @path_helper = path_helper @model = model @params = params @context = context @icon = icon.to_sym end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
5 6 7 |
# File 'lib/sortable_by/table_header.rb', line 5 def context @context end |
#header_html ⇒ Object
Returns the value of attribute header_html.
6 7 8 |
# File 'lib/sortable_by/table_header.rb', line 6 def header_html @header_html end |
Instance Method Details
#capture(block) ⇒ Object
19 20 21 22 23 |
# File 'lib/sortable_by/table_header.rb', line 19 def capture(block) @html = context.capture do block.call(self) end end |
#header(attribute, label: nil) ⇒ Object
32 33 34 35 |
# File 'lib/sortable_by/table_header.rb', line 32 def header(attribute, label: nil) label ||= translated_attribute(attribute) content_tag :th, label end |
#sortable(attribute, label: nil) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/sortable_by/table_header.rb', line 25 def sortable(attribute, label: nil) content_tag :th, class: classes_for_attribute(attribute) do concat(link_to_for_attribute(attribute, label)) concat(sort_arrow_for_attribute(attribute)) end end |
#to_html ⇒ Object
41 42 43 |
# File 'lib/sortable_by/table_header.rb', line 41 def to_html content_tag :thead, to_row, class: 'sortable-table-header' end |
#to_row ⇒ Object
37 38 39 |
# File 'lib/sortable_by/table_header.rb', line 37 def to_row content_tag(:tr, @html) end |