Class: PaginatedTable::TableDescription::Column
- Inherits:
-
Object
- Object
- PaginatedTable::TableDescription::Column
- Defined in:
- lib/paginated_table/view_helpers.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #html_attributes ⇒ Object
-
#initialize(name, options = {}, &block) ⇒ Column
constructor
A new instance of Column.
- #render_cell(datum) ⇒ Object
- #render_header ⇒ Object
- #sortable? ⇒ Boolean
Constructor Details
#initialize(name, options = {}, &block) ⇒ Column
Returns a new instance of Column.
26 27 28 29 30 |
# File 'lib/paginated_table/view_helpers.rb', line 26 def initialize(name, = {}, &block) @name = name @block = block @options = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
24 25 26 |
# File 'lib/paginated_table/view_helpers.rb', line 24 def name @name end |
Instance Method Details
#html_attributes ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/paginated_table/view_helpers.rb', line 48 def html_attributes html_attributes = {} if @options[:class] html_attributes[:class] = Array(@options[:class]).join(' ') end if @options[:style] html_attributes[:style] = @options[:style] end html_attributes end |
#render_cell(datum) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/paginated_table/view_helpers.rb', line 36 def render_cell(datum) if @block @block.call(datum) else datum.send(@name) end end |
#render_header ⇒ Object
32 33 34 |
# File 'lib/paginated_table/view_helpers.rb', line 32 def render_header @options.fetch(:title, @name.to_s.titleize) end |
#sortable? ⇒ Boolean
44 45 46 |
# File 'lib/paginated_table/view_helpers.rb', line 44 def sortable? @options.fetch(:sortable, true) end |