Class: AjaxDatatablesRails::Datatable::SimpleOrder
- Inherits:
-
Object
- Object
- AjaxDatatablesRails::Datatable::SimpleOrder
- Defined in:
- lib/ajax-datatables-rails/datatable/simple_order.rb
Constant Summary collapse
- DIRECTION_ASC =
'ASC'
- DIRECTION_DESC =
'DESC'
- DIRECTIONS =
[DIRECTION_ASC, DIRECTION_DESC].freeze
Instance Method Summary collapse
- #column ⇒ Object
- #direction ⇒ Object
-
#initialize(datatable, options = {}) ⇒ SimpleOrder
constructor
A new instance of SimpleOrder.
- #query(sort_column) ⇒ Object
Constructor Details
#initialize(datatable, options = {}) ⇒ SimpleOrder
Returns a new instance of SimpleOrder.
11 12 13 14 15 16 |
# File 'lib/ajax-datatables-rails/datatable/simple_order.rb', line 11 def initialize(datatable, = {}) @datatable = datatable @options = @adapter = datatable.db_adapter @nulls_last = datatable.nulls_last end |
Instance Method Details
#column ⇒ Object
22 23 24 |
# File 'lib/ajax-datatables-rails/datatable/simple_order.rb', line 22 def column @datatable.column_by(:index, column_index) end |
#direction ⇒ Object
26 27 28 |
# File 'lib/ajax-datatables-rails/datatable/simple_order.rb', line 26 def direction DIRECTIONS.find { |dir| dir == column_direction } || DIRECTION_ASC end |
#query(sort_column) ⇒ Object
18 19 20 |
# File 'lib/ajax-datatables-rails/datatable/simple_order.rb', line 18 def query(sort_column) [sort_column, direction, nulls_last_sql].compact.join(' ') end |