Module: ArToHtmlTable::ColumnFormats::InstanceMethods

Defined in:
lib/ar_to_html_table/column_formats.rb

Instance Method Summary collapse

Instance Method Details

#format_column(column_name) ⇒ Object Also known as: format_attribute

Invoke the formatter on a column.

Examples

class Product < ActiveRecord::Base
  column_format :name,      :order => 1
  column_format :orders,    :total => :sum
  column_format :revenue,   :total => :sum, :order => 5, :class => 'right'
  column_format :age, 	    :total => :avg, :order => 20, :class => 'right', :formatter => :number_with_delimiter
end

# p = Product.first
# p.age
=> 4346

# p.format_column(:age)
=> "4,346"

Parameters

column_name:  A column (attribute) on the the model instance


34
35
36
# File 'lib/ar_to_html_table/column_formats.rb', line 34

def format_column(column_name)
  self.class.format_column(column_name, self[column_name])
end