Module: TableSortable::Controller
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/table_sortable/controller.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#column_offset ⇒ Object
readonly
Returns the value of attribute column_offset.
-
#column_order ⇒ Object
readonly
Returns the value of attribute column_order.
-
#template_path ⇒ Object
readonly
Returns the value of attribute template_path.
-
#translation_key ⇒ Object
readonly
Returns the value of attribute translation_key.
Instance Method Summary collapse
- #columns ⇒ Object
- #define_column(col_name, *options) ⇒ Object
- #define_column_offset(offset) ⇒ Object
- #define_column_order(*order) ⇒ Object
- #define_columns(*args) ⇒ Object
- #define_template_path(path) ⇒ Object
- #define_translation_key(key) ⇒ Object
Instance Attribute Details
#column_offset ⇒ Object (readonly)
Returns the value of attribute column_offset.
129 130 131 |
# File 'lib/table_sortable/controller.rb', line 129 def column_offset @column_offset end |
#column_order ⇒ Object (readonly)
Returns the value of attribute column_order.
129 130 131 |
# File 'lib/table_sortable/controller.rb', line 129 def column_order @column_order end |
#template_path ⇒ Object (readonly)
Returns the value of attribute template_path.
129 130 131 |
# File 'lib/table_sortable/controller.rb', line 129 def template_path @template_path end |
#translation_key ⇒ Object (readonly)
Returns the value of attribute translation_key.
129 130 131 |
# File 'lib/table_sortable/controller.rb', line 129 def translation_key @translation_key end |
Instance Method Details
#columns ⇒ Object
87 88 89 |
# File 'lib/table_sortable/controller.rb', line 87 def columns @columns.sort_by(column_order) end |
#define_column(col_name, *options) ⇒ Object
66 67 68 69 |
# File 'lib/table_sortable/controller.rb', line 66 def define_column(col_name, *) = .merge(.) @columns.add(col_name, .merge(controller: self)) end |
#define_column_offset(offset) ⇒ Object
75 76 77 |
# File 'lib/table_sortable/controller.rb', line 75 def define_column_offset(offset) @column_offset = offset end |
#define_column_order(*order) ⇒ Object
71 72 73 |
# File 'lib/table_sortable/controller.rb', line 71 def define_column_order(*order) @column_order = order end |
#define_columns(*args) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/table_sortable/controller.rb', line 52 def define_columns(*args) = args. column_offset = [:offset] || 0 translation_key = [:translation_key] template_path = [:template_path] columns = args define_translation_key translation_key define_template_path template_path define_column_offset column_offset columns.each do |column| define_column column, translation_key: translation_key end end |
#define_template_path(path) ⇒ Object
83 84 85 |
# File 'lib/table_sortable/controller.rb', line 83 def define_template_path(path) @template_path = path.blank? ? nil : File.join(path, "") end |
#define_translation_key(key) ⇒ Object
79 80 81 |
# File 'lib/table_sortable/controller.rb', line 79 def define_translation_key(key) @translation_key = key end |