7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/has_dynamic_columns/active_record/v3/query_methods.rb', line 7
def self.included base
base.class_eval do
def preprocess_order_args(order_args)
order_args.flatten!
references = order_args.grep(String)
references.map! { |arg| arg =~ /^([a-zA-Z]\w*)\.(\w+)/ && $1 }.compact!
references!(references) if references.any?
order_args.map! do |arg|
case arg
when Symbol
table[arg].asc
when Hash
arg.map { |field, dir|
table[field].send(dir.downcase)
}
else
arg
end
end.flatten!
end
end
end
|