aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorAndrew White <pixeltrix@users.noreply.github.com>2017-05-20 16:40:53 +0100
committerGitHub <noreply@github.com>2017-05-20 16:40:53 +0100
commitffa693d250cf382c39cd75fa07deb1b43b9bd148 (patch)
tree99385e094f414e8bc158930cc5e2cc3818120672 /activerecord/lib/active_record
parentac3564693c6df9c9f9a46f681f4f6a4ea84997e6 (diff)
parent0d874b4a5a39646bbfc3e062db62a3b3ab68b47c (diff)
downloadrails-ffa693d250cf382c39cd75fa07deb1b43b9bd148.tar.gz
rails-ffa693d250cf382c39cd75fa07deb1b43b9bd148.tar.bz2
rails-ffa693d250cf382c39cd75fa07deb1b43b9bd148.zip
Merge pull request #29156 from kamipo/make_valid_directions_to_set
Make `VALID_DIRECTIONS` to `Set`
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index 76e529f2de..79e65baae5 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -1100,14 +1100,16 @@ module ActiveRecord
end
VALID_DIRECTIONS = [:asc, :desc, :ASC, :DESC,
- "asc", "desc", "ASC", "DESC"] # :nodoc:
+ "asc", "desc", "ASC", "DESC"].to_set # :nodoc:
def validate_order_args(args)
args.each do |arg|
next unless arg.is_a?(Hash)
arg.each do |_key, value|
- raise ArgumentError, "Direction \"#{value}\" is invalid. Valid " \
- "directions are: #{VALID_DIRECTIONS.inspect}" unless VALID_DIRECTIONS.include?(value)
+ unless VALID_DIRECTIONS.include?(value)
+ raise ArgumentError,
+ "Direction \"#{value}\" is invalid. Valid directions are: #{VALID_DIRECTIONS.to_a.inspect}"
+ end
end
end
end