Class: TableHelper::SimpleColumn

Inherits:
Column
  • Object
show all
Defined in:
lib/table_for/simple_column.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Column

#html, #title

Instance Method Summary collapse

Methods inherited from Column

#draw_title, #initialize

Constructor Details

This class inherits a constructor from TableHelper::Column

Instance Method Details

#content_for(record) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/table_for/simple_column.rb', line 3

def content_for(record)
  called_record = record.kind_of?(Hash) ? record[@attr] : record.send(@attr)

  if @options[:attr] && called_record.respond_to?(@options[:attr])
    called_record = called_record.send(@options[:attr])
  end

  if @options[:default] && called_record.nil?
    called_record = @options[:default]
  end

  if @options[:time_format] and called_record.is_a? Time
    called_record = called_record.strftime(@options[:time_format])
  end
  called_record.to_s
end