Class: IndexView::Column
- Inherits:
-
Object
- Object
- IndexView::Column
- Defined in:
- lib/index_view/column.rb
Defined Under Namespace
Classes: InvalidKeyError
Constant Summary collapse
- OPTION_KEYS =
[:link, :sortable, :title, :searchable]
Instance Attribute Summary collapse
-
#column_name ⇒ Object
readonly
Returns the value of attribute column_name.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
Instance Method Summary collapse
- #column_value(context, object) ⇒ Object
- #column_value? ⇒ Boolean
- #human_name ⇒ Object
-
#initialize(column_name, options = { }, &link) ⇒ Column
constructor
A new instance of Column.
- #searchable? ⇒ Boolean
- #sortable? ⇒ Boolean
- #title ⇒ Object
Constructor Details
#initialize(column_name, options = { }, &link) ⇒ Column
Returns a new instance of Column.
7 8 9 10 11 |
# File 'lib/index_view/column.rb', line 7 def initialize(column_name, ={ }, &link) @column_name = column_name.to_sym check_and_assign_values_from_keys(, link) end |
Instance Attribute Details
#column_name ⇒ Object (readonly)
Returns the value of attribute column_name.
13 14 15 |
# File 'lib/index_view/column.rb', line 13 def column_name @column_name end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
13 14 15 |
# File 'lib/index_view/column.rb', line 13 def link @link end |
Instance Method Details
#column_value(context, object) ⇒ Object
15 16 17 |
# File 'lib/index_view/column.rb', line 15 def column_value(context, object) context.instance_exec(object, &link) end |
#column_value? ⇒ Boolean
19 20 21 |
# File 'lib/index_view/column.rb', line 19 def column_value? link ? true : false end |
#human_name ⇒ Object
27 28 29 |
# File 'lib/index_view/column.rb', line 27 def human_name column_name.to_s.humanize end |
#searchable? ⇒ Boolean
35 36 37 |
# File 'lib/index_view/column.rb', line 35 def searchable? @searchable ? true : false end |
#sortable? ⇒ Boolean
23 24 25 |
# File 'lib/index_view/column.rb', line 23 def sortable? @sortable ? true : false end |
#title ⇒ Object
31 32 33 |
# File 'lib/index_view/column.rb', line 31 def title @title ? @title : human_name end |