Parent

Class/Module Index [+]

Quicksearch

Mongoid::Contexts::Enumerable::Sort

Attributes

direction[R]
value[R]

Public Instance Methods

<=>(other) click to toggle source

Compare two Sort objects against each other, taking into consideration the direction of the sorting.

# File lib/mongoid/contexts/enumerable/sort.rb, line 21
def <=>(other)
  cmp = compare(value, other.value)
  ascending? ? cmp : cmp * -1
end
ascending?() click to toggle source

Return true if the direction is :asc, otherwise false.

# File lib/mongoid/contexts/enumerable/sort.rb, line 15
def ascending?
  direction == :asc
end

Public Class Methods

new(value, direction) click to toggle source

Create a new sorting object. This requires a value and a sort direction of :asc or :desc.

# File lib/mongoid/contexts/enumerable/sort.rb, line 9
def initialize(value, direction)
  @value     = value
  @direction = direction
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.