Class: TableColumn

Inherits:
Object
  • Object
show all
Defined in:
lib/define_columns/table_column.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ TableColumn

Returns a new instance of TableColumn.



5
6
7
# File 'lib/define_columns/table_column.rb', line 5

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/define_columns/table_column.rb', line 3

def name
  @name
end

Instance Method Details

#apply(&blk) ⇒ Object



22
23
24
# File 'lib/define_columns/table_column.rb', line 22

def apply(&blk)
  @proc = blk
end

#headerObject



9
10
11
# File 'lib/define_columns/table_column.rb', line 9

def header
  @name.humanize
end

#show(subject) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/define_columns/table_column.rb', line 13

def show(subject)
  if defined?(@proc)
    @proc.call subject.send(@name.to_sym)
  else
    subject.send @name.to_sym
  end

end