Class: SortingTableFor::FormatCell
- Inherits:
-
FormatLine
- Object
- TableBuilder
- FormatLine
- SortingTableFor::FormatCell
- Defined in:
- lib/sorting_table_for/format_cell.rb
Instance Method Summary collapse
-
#initialize(object, args, type = nil, block = nil) ⇒ FormatCell
constructor
A new instance of FormatCell.
-
#render_cell_tbody ⇒ Object
Return a td with the formated value or action for columns.
- #render_cell_tfoot ⇒ Object
-
#render_cell_thead ⇒ Object
Return a td with the formated value or action for headers.
Methods inherited from FormatLine
#add_cell, #render_line, #total_cells
Methods inherited from TableBuilder
#caption, #column, #columns, #footer, #footers, #header, #headers
Constructor Details
#initialize(object, args, type = nil, block = nil) ⇒ FormatCell
Returns a new instance of FormatCell.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/sorting_table_for/format_cell.rb', line 4 def initialize(object, args, type = nil, block = nil) @object, @type, @block = object, type, block if args.is_a? Array @options, @html_options = ( args. ) @ask = args.first if @ask.nil? and @options.has_key?(:action) @type = :action @ask = @options[:action] end else @ask = args end can_sort_column? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class SortingTableFor::TableBuilder
Instance Method Details
#render_cell_tbody ⇒ Object
Return a td with the formated value or action for columns
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sorting_table_for/format_cell.rb', line 21 def render_cell_tbody if @type == :action cell_value = action_link_to(@ask) elsif @ask cell_value = (@ask.is_a?(Symbol)) ? format_cell_value(@object[@ask], @ask) : format_cell_value(@ask) else cell_value = @block end cell_value = action_link_to(@options[:action], cell_value) if @type != :action and @options.has_key?(:action) content_tag(:td, cell_value, @html_options) end |
#render_cell_tfoot ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/sorting_table_for/format_cell.rb', line 49 def render_cell_tfoot if @ask cell_value = (@ask.is_a?(Symbol)) ? I18n.t(@ask, {}, :footer) : @ask else cell_value = @block end cell_value = action_link_to(@options[:action], cell_value) if @type != :action and @options.has_key?(:action) content_tag(:td, cell_value, @html_options) end |
#render_cell_thead ⇒ Object
Return a td with the formated value or action for headers
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/sorting_table_for/format_cell.rb', line 34 def render_cell_thead if @ask cell_value = (@ask.is_a?(Symbol)) ? I18n.t(@ask, {}, :header) : @ask else cell_value = @block end if @can_sort sort_on = @options[:sort_as] || @ask @html_options.merge!(:class => "#{@html_options[:class]} #{sorting_html_class(sort_on)}".strip) content_tag(:th, sort_link_to(cell_value, sort_on), @html_options) else content_tag(:th, cell_value, @html_options) end end |