Class: Trestle::Table::Column
- Inherits:
-
Object
- Object
- Trestle::Table::Column
- Defined in:
- lib/trestle/table/column.rb
Defined Under Namespace
Classes: Renderer
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(field, options = {}, &block) ⇒ Column
constructor
A new instance of Column.
- #renderer(table:, template:) ⇒ Object
- #sort_field ⇒ Object
- #sort_options ⇒ Object
- #sortable? ⇒ Boolean
Constructor Details
#initialize(field, options = {}, &block) ⇒ Column
Returns a new instance of Column.
6 7 8 9 |
# File 'lib/trestle/table/column.rb', line 6 def initialize(field, ={}, &block) @field, @options = field, @block = block if block_given? end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
4 5 6 |
# File 'lib/trestle/table/column.rb', line 4 def block @block end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
4 5 6 |
# File 'lib/trestle/table/column.rb', line 4 def field @field end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/trestle/table/column.rb', line 4 def @options end |
Instance Method Details
#renderer(table:, template:) ⇒ Object
11 12 13 |
# File 'lib/trestle/table/column.rb', line 11 def renderer(table:, template:) Renderer.new(self, table: table, template: template) end |
#sort_field ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/trestle/table/column.rb', line 19 def sort_field if [:sort].is_a?(Hash) [:sort][:field] || field else [:sort] || field end end |
#sort_options ⇒ Object
27 28 29 |
# File 'lib/trestle/table/column.rb', line 27 def [:sort].is_a?(Hash) ? [:sort] : {} end |
#sortable? ⇒ Boolean
15 16 17 |
# File 'lib/trestle/table/column.rb', line 15 def sortable? [:sort] != false && (!@block || .has_key?(:sort)) end |