Class: ExpressTemplates::Components::TableFor::Column
- Inherits:
-
Object
- Object
- ExpressTemplates::Components::TableFor::Column
- Defined in:
- lib/express_templates/components/table_for.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #format(item_name) ⇒ Object
-
#initialize(name, options = {}) ⇒ Column
constructor
A new instance of Column.
- #title ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ Column
Returns a new instance of Column.
97 98 99 100 101 |
# File 'lib/express_templates/components/table_for.rb', line 97 def initialize(name, = {}) @name = name @options = @formatter = [:formatter] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
96 97 98 |
# File 'lib/express_templates/components/table_for.rb', line 96 def name @name end |
Instance Method Details
#format(item_name) ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/express_templates/components/table_for.rb', line 103 def format(item_name) if @formatter.nil? "\#\{#{item_name}.#{name}\}" elsif @formatter.kind_of?(Proc) "\#\{(#{@formatter.source}).call(#{item_name}.#{name})\}" end end |
#title ⇒ Object
111 112 113 |
# File 'lib/express_templates/components/table_for.rb', line 111 def title @name.to_s.try(:titleize) end |