From 2a365e2d460322514396c821af9c7d3177a69b29 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Sat, 2 May 2009 13:56:10 -0300 Subject: [PATCH] Improve reverse_sql_order: there is no need to define local variable, removed last redundant elsif. --- activerecord/lib/active_record/base.rb | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 97c36a6..f0167cc 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1537,12 +1537,12 @@ module ActiveRecord #:nodoc: end def reverse_sql_order(order_query) - reversed_query = order_query.to_s.split(/,/).each { |s| + order_query.to_s.split(/,/).each { |s| if s.match(/\s(asc|ASC)$/) s.gsub!(/\s(asc|ASC)$/, ' DESC') elsif s.match(/\s(desc|DESC)$/) s.gsub!(/\s(desc|DESC)$/, ' ASC') - elsif !s.match(/\s(asc|ASC|desc|DESC)$/) + else s.concat(' DESC') end }.join(',') -- 1.5.5.1