diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-19 19:27:48 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-19 19:27:48 -0700 |
commit | 9e5ee49ec55b9cb1c2b4444dee58f3dfaefc7c7e (patch) | |
tree | b6f762f065574a6394da1a4c70efb874802d6677 /lib/arel/relations/operations/order.rb | |
parent | 5a5501cde76bbba69bcea27d3d0efeaffa3e3bf5 (diff) | |
download | rails-9e5ee49ec55b9cb1c2b4444dee58f3dfaefc7c7e.tar.gz rails-9e5ee49ec55b9cb1c2b4444dee58f3dfaefc7c7e.tar.bz2 rails-9e5ee49ec55b9cb1c2b4444dee58f3dfaefc7c7e.zip |
some drying up of boiler plate initialization and equality code
Diffstat (limited to 'lib/arel/relations/operations/order.rb')
-rw-r--r-- | lib/arel/relations/operations/order.rb | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/arel/relations/operations/order.rb b/lib/arel/relations/operations/order.rb index ebb4dc0668..82924806e2 100644 --- a/lib/arel/relations/operations/order.rb +++ b/lib/arel/relations/operations/order.rb @@ -1,19 +1,16 @@ module Arel class Order < Compound - attr_reader :orderings + attributes :relation, :orderings + deriving :== - def initialize(relation, *orderings) - @relation, @orderings = relation, orderings.collect { |o| o.bind(relation) } + def initialize(relation, *orderings, &block) + @relation = relation + @orderings = (orderings + (block_given?? [yield(self)] : [])).collect { |o| o.bind(relation) } end + # TESTME def orders - orderings + relation.orders - end - - def ==(other) - Order === other and - relation == other.relation and - orderings == other.orderings + (orderings + relation.orders).collect { |o| o.bind(self) } end end end
\ No newline at end of file |