lib/rest_framework/filters.rb
def _get_ordering
    return nil if @controller.class.ordering_query_param.blank?
    ordering_fields = @controller.send(:get_ordering_fields)
    order_string = @controller.params[@controller.class.ordering_query_param]

    unless order_string.blank?
      ordering = {}
      order_string.split(',').each do |field|
        if field[0] == '-'
          column = field[1..-1]
          direction = :desc
        else
          column = field
          direction = :asc
        end
        if column.in?(ordering_fields)
          ordering[column.to_sym] = direction
        end
      end
      return ordering
    end

    return nil
  end
# Convert ordering string to an ordering configuration.
Convert ordering string to an ordering configuration.
Convert ordering string to an ordering configuration .
def _get_ordering
    return nil if @controller.class.ordering_query_param.blank?
    ordering_fields = @controller.send(:get_ordering_fields)
    order_string = @controller.params[@controller.class.ordering_query_param]
    unless order_string.blank?
      ordering = {}
      order_string.split(',').each do |field|
        if field[0] == '-'
          column = field[1..-1]
          direction = :desc
        else
          column = field
          direction = :asc
        end
        if column.in?(ordering_fields)
          ordering[column.to_sym] = direction
        end
      end
      return ordering
    end
    return nil
  end
def _get_ordering return nil if @controller . class . ordering_query_param . blank? ordering_fields = @controller . send ( :get_ordering_fields ) order_string = @controller . params [ @controller . class . ordering_query_param ] unless order_string . blank? ordering = { } order_string . split ( ',' ) . each do | field | if field [ 0 ] == '-' column = field [ 1 .. - 1 ] direction = :desc else column = field direction = :asc end if column . in? ( ordering_fields ) ordering [ column . to_sym ] = direction end end return ordering end return nil end
Convert ordering string to an ordering configuration.
Convert ordering string to an ordering configuration .