Class: TableHelper::Column
- Inherits:
-
Object
- Object
- TableHelper::Column
- Defined in:
- lib/table_for/column.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Attribute Summary collapse
-
#html ⇒ Object
readonly
Returns the value of attribute html.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #content_for ⇒ Object
- #draw_title ⇒ Object
-
#initialize(template, records, obj, ops = {}) ⇒ Column
constructor
A new instance of Column.
Constructor Details
#initialize(template, records, obj, ops = {}) ⇒ Column
Returns a new instance of Column.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/table_for/column.rb', line 6 def initialize(template, records, obj, ops={}) @template, @attr, @options = template, obj, ops @title = if @options[:title] @options.delete(:title) elsif @attr.nil? " " elsif records.class.respond_to?(:human_attribute_name) records.class.human_attribute_name(@attr.to_s) elsif @attr.to_s.respond_to?(:humanize) @attr.to_s.humanize else @attr.to_s.capitalize end @title_callback = @options.delete(:title_callback) @html = @options.delete(:html) || {} @html.merge!({:th => { :width => @options.delete(:width) }}) if @options.has_key?(:width) end |
Instance Attribute Details
#html ⇒ Object (readonly)
Returns the value of attribute html.
3 4 5 |
# File 'lib/table_for/column.rb', line 3 def html @html end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
3 4 5 |
# File 'lib/table_for/column.rb', line 3 def title @title end |
Instance Method Details
#content_for ⇒ Object
27 28 29 |
# File 'lib/table_for/column.rb', line 27 def content_for raise NoMethodError, "Use SimpleColumn or CallbackColumn" end |
#draw_title ⇒ Object
31 32 33 34 35 |
# File 'lib/table_for/column.rb', line 31 def draw_title content_tag :th, @html[:th] do @title_callback.is_a?(Proc) ? @title_callback.call(@title) : @title end end |