Class: Warped::Table::Column
- Inherits:
-
Object
- Object
- Warped::Table::Column
- Defined in:
- lib/warped/table/column.rb
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#parameter_name ⇒ Object
readonly
Returns the value of attribute parameter_name.
Instance Method Summary collapse
- #content_for(record) ⇒ Object
- #display_name ⇒ Object
-
#initialize(parameter_name, display_name = nil, method: nil, **options) ⇒ Column
constructor
A new instance of Column.
Constructor Details
#initialize(parameter_name, display_name = nil, method: nil, **options) ⇒ Column
Returns a new instance of Column.
14 15 16 17 18 19 |
# File 'lib/warped/table/column.rb', line 14 def initialize(parameter_name, display_name = nil, method: nil, **) @parameter_name = parameter_name @display_name = display_name @options = @method = method.presence || parameter_name end |
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method.
9 10 11 |
# File 'lib/warped/table/column.rb', line 9 def method @method end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/warped/table/column.rb', line 9 def @options end |
#parameter_name ⇒ Object (readonly)
Returns the value of attribute parameter_name.
9 10 11 |
# File 'lib/warped/table/column.rb', line 9 def parameter_name @parameter_name end |
Instance Method Details
#content_for(record) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/warped/table/column.rb', line 25 def content_for(record) if method.is_a?(Proc) method.call(record) else record.public_send(method) end end |
#display_name ⇒ Object
21 22 23 |
# File 'lib/warped/table/column.rb', line 21 def display_name @display_name.presence || parameter_name.to_s.humanize end |