Class: PaginatedTable::ColumnDescription
- Inherits:
-
Object
- Object
- PaginatedTable::ColumnDescription
- Defined in:
- lib/paginated_table/column_description.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #html_attributes ⇒ Object
-
#initialize(row, name, options = {}, &block) ⇒ ColumnDescription
constructor
A new instance of ColumnDescription.
- #render_cell(datum) ⇒ Object
- #render_header ⇒ Object
- #sortable? ⇒ Boolean
- #span ⇒ Object
Constructor Details
#initialize(row, name, options = {}, &block) ⇒ ColumnDescription
Returns a new instance of ColumnDescription.
5 6 7 8 9 10 |
# File 'lib/paginated_table/column_description.rb', line 5 def initialize(row, name, = {}, &block) @row = row @name = name @block = block = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/paginated_table/column_description.rb', line 3 def name @name end |
Instance Method Details
#html_attributes ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/paginated_table/column_description.rb', line 32 def html_attributes html_attributes = {} if [:class] html_attributes[:class] = Array([:class]).join(' ') end if [:style] html_attributes[:style] = [:style] end if span html_attributes[:colspan] = @row.colspan(span) end html_attributes end |
#render_cell(datum) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/paginated_table/column_description.rb', line 16 def render_cell(datum) if @block @block.call(datum) else datum.send(@name) end end |
#render_header ⇒ Object
12 13 14 |
# File 'lib/paginated_table/column_description.rb', line 12 def render_header .fetch(:title, @name.to_s.titleize) end |
#sortable? ⇒ Boolean
24 25 26 |
# File 'lib/paginated_table/column_description.rb', line 24 def sortable? .fetch(:sortable, true) end |
#span ⇒ Object
28 29 30 |
# File 'lib/paginated_table/column_description.rb', line 28 def span .fetch(:span, false) end |