Sha256: b865d86f32c96e580cff477aa214e4273da7d33d77e792ace541ab0f901b6ec8

Contents?: true

Size: 608 Bytes

Versions: 1

Compression:

Stored size: 608 Bytes

Contents

module AjaxDatatablesRails
  module Datatable
    class SimpleOrder
      attr_reader :datatable, :options

      DIRECTIONS = %w(DESC ASC)

      def initialize(datatable, options)
        @datatable = datatable
        @options = options || {}
      end

      def query sort_column
        "#{ sort_column } #{ dir }"
      end

      def column
        datatable.column_by(:index, column_index)
      end

      private
      def dir
        DIRECTIONS.find { |direction| direction == options[:dir].upcase } || 'ASC'
      end

      def column_index
        options[:column]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
datatables-net-0.4.0 lib/ajax-datatables-rails/datatable/simple_order.rb