Class: DiningTable::Columns::Column
- Inherits:
-
Object
- Object
- DiningTable::Columns::Column
- Defined in:
- lib/dining-table/columns/column.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#table ⇒ Object
Returns the value of attribute table.
Instance Method Summary collapse
- #footer ⇒ Object
- #header ⇒ Object
-
#initialize(table, name, options = {}, &block) ⇒ Column
constructor
A new instance of Column.
- #options_for(identifier) ⇒ Object
- #value(object) ⇒ Object
Constructor Details
#initialize(table, name, options = {}, &block) ⇒ Column
Returns a new instance of Column.
9 10 11 12 13 14 |
# File 'lib/dining-table/columns/column.rb', line 9 def initialize( table, name, = {}, &block) self.table = table self.name = name self. = self.block = block end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
7 8 9 |
# File 'lib/dining-table/columns/column.rb', line 7 def block @block end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/dining-table/columns/column.rb', line 7 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/dining-table/columns/column.rb', line 7 def end |
#table ⇒ Object
Returns the value of attribute table.
7 8 9 |
# File 'lib/dining-table/columns/column.rb', line 7 def table @table end |
Instance Method Details
#footer ⇒ Object
33 34 35 |
# File 'lib/dining-table/columns/column.rb', line 33 def ||= determine_label(:footer) end |
#header ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/dining-table/columns/column.rb', line 24 def header @header ||= begin label = determine_label(:header) return label if label object_class = table.collection.first.class if table.collection.first object_class.human_attribute_name( name ) if object_class && object_class.respond_to?( :human_attribute_name ) end end |
#options_for(identifier) ⇒ Object
37 38 39 |
# File 'lib/dining-table/columns/column.rb', line 37 def (identifier) [ identifier ] || { } end |
#value(object) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/dining-table/columns/column.rb', line 16 def value(object) if block block.call(object, self) else object.send(name) if object.respond_to?(name) end end |