Class: TableColumn
- Inherits:
-
Object
- Object
- TableColumn
- Defined in:
- lib/define_columns/table_column.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #apply(&blk) ⇒ Object
- #header ⇒ Object
-
#initialize(name) ⇒ TableColumn
constructor
A new instance of TableColumn.
- #show(subject) ⇒ Object
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
#name ⇒ Object
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 |
#header ⇒ Object
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 |