Last Updated: February 25, 2016
·
381
· roxasshadow

Provide DataMapper with a default sorting method

dm-sorting is a gem allowing you to define in a clear way the default criterium to sort your data.

Install

$ gem install dm-sorting

Example

require 'dm-core'
require 'dm-sorting'

class Person
  include DataMapper::Resource

  property :id,     Serial
  property :name,   String
  property :age,    Integer

  sort_by :name.asc, :age.desc # default_order and order_by are available too
end