lib/searchlogic/named_scopes/ordering.rb in searchlogic-2.1.12 vs lib/searchlogic/named_scopes/ordering.rb in searchlogic-2.1.13

- old
+ new

@@ -17,16 +17,20 @@ end def order_condition?(name) # :nodoc: !order_condition_details(name).nil? end + + def custom_order_condition?(name) # :nodoc: + !custom_order_condition_details(name).nil? + end private def method_missing(name, *args, &block) if name == :order named_scope name, lambda { |scope_name| - return {} if !order_condition?(scope_name) + return {} if !order_condition?(scope_name) && !custom_order_condition?(scope_name) && !association_ordering_condition?(scope_name) send(scope_name).proxy_options } send(name, *args) elsif details = order_condition_details(name) create_order_conditions(details[:column]) @@ -39,9 +43,15 @@ def order_condition_details(name) if name.to_s =~ /^(ascend|descend)_by_(#{column_names.join("|")})$/ {:order_as => $1, :column => $2} elsif name.to_s =~ /^order$/ {} + end + end + + def custom_order_condition_details(name) + if name.to_s =~ /^(ascend|descend)_by_(.+)$/ + {:order_as => $1, :scope => name.to_sym} end end def create_order_conditions(column) named_scope("ascend_by_#{column}".to_sym, {:order => "#{table_name}.#{column} ASC"}) \ No newline at end of file