diff options
author | Ernie Miller <ernie@metautonomo.us> | 2010-09-29 20:08:57 -0400 |
---|---|---|
committer | Ernie Miller <ernie@metautonomo.us> | 2010-09-29 20:08:57 -0400 |
commit | eef61ab909b614ce6f2d100cfb50044c063bc24a (patch) | |
tree | eaa50f239fab9b1b3ed88be89ba743b5724fb19a /lib/arel/nodes | |
parent | f5b76c220ed6583628a84fd899fbb24c39c997ee (diff) | |
download | rails-eef61ab909b614ce6f2d100cfb50044c063bc24a.tar.gz rails-eef61ab909b614ce6f2d100cfb50044c063bc24a.tar.bz2 rails-eef61ab909b614ce6f2d100cfb50044c063bc24a.zip |
Support Attribute#asc and Attribute#desc to create orderings
Diffstat (limited to 'lib/arel/nodes')
-rw-r--r-- | lib/arel/nodes/ordering.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/arel/nodes/ordering.rb b/lib/arel/nodes/ordering.rb new file mode 100644 index 0000000000..d395c8631d --- /dev/null +++ b/lib/arel/nodes/ordering.rb @@ -0,0 +1,19 @@ +module Arel + module Nodes + class Ordering < Arel::Nodes::Node + attr_accessor :expr, :direction + + def initialize expression, direction = :asc + @expr, @direction = expression, direction + end + + def ascending? + direction == :asc + end + + def descending? + direction == :desc + end + end + end +end |