-
Notifications
You must be signed in to change notification settings - Fork 0
/
header_row.rb
31 lines (25 loc) · 845 Bytes
/
header_row.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class Views::Things::Index < Views::Base
class TableWidget < Views::Base
# Generic table-header row; needs an array of symbolised field names.
class HeaderRow < Views::Base
# Methods that neither affect nor depend on instance state.
module Internals
def self.item_string(item)
item.to_s.humanize.titlecase
end
end
private_constant :Internals
needs :fields
def content
tr { header_captions.each { |caption| item_widget caption } }
end
private
def header_captions
fields.map { |item| Internals.item_string(item) }
end
def item_widget(caption)
th { text caption }
end
end # class Views::Things::Index::TableWidget::HeaderRow
end # class Views::Things::Index::TableWidget
end # class Views::Things::Index