diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-02-20 12:02:01 -0800 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-02-20 12:02:01 -0800 |
commit | 24b7a769bfbf20b066081dc73c4e29c03a9eb428 (patch) | |
tree | 99f172c5fd383b23fcb3111fd721a86e3a8f913c /activerecord/lib/active_record/relation | |
parent | aeb4592006f99f9db2e1fe95ecbff45d4c1d478d (diff) | |
parent | 7b30cec764d7132b194816f42cc1504a841ce195 (diff) | |
download | rails-24b7a769bfbf20b066081dc73c4e29c03a9eb428.tar.gz rails-24b7a769bfbf20b066081dc73c4e29c03a9eb428.tar.bz2 rails-24b7a769bfbf20b066081dc73c4e29c03a9eb428.zip |
Merge pull request #9345 from wangjohn/change_name_of_query_method_argument_checker_for_clarity
Renaming the check_empty_arguments method to something more descriptive.
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index d9ed22b948..20e23cb003 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -112,7 +112,7 @@ module ActiveRecord # # User.includes(:posts).where('posts.name = ?', 'example').references(:posts) def includes(*args) - check_empty_arguments("includes", args) + has_arguments?("includes", args) spawn.includes!(*args) end @@ -130,7 +130,7 @@ module ActiveRecord # FROM "users" LEFT OUTER JOIN "posts" ON "posts"."user_id" = # "users"."id" def eager_load(*args) - check_empty_arguments("eager_load", args) + has_arguments?("eager_load", args) spawn.eager_load!(*args) end @@ -144,7 +144,7 @@ module ActiveRecord # User.preload(:posts) # => SELECT "posts".* FROM "posts" WHERE "posts"."user_id" IN (1, 2, 3) def preload(*args) - check_empty_arguments("preload", args) + has_arguments?("preload", args) spawn.preload!(*args) end @@ -162,7 +162,7 @@ module ActiveRecord # User.includes(:posts).where("posts.name = 'foo'").references(:posts) # # => Query now knows the string references posts, so adds a JOIN def references(*args) - check_empty_arguments("references", args) + has_arguments?("references", args) spawn.references!(*args) end @@ -242,7 +242,7 @@ module ActiveRecord # User.group('name AS grouped_name, age') # => [#<User id: 3, name: "Foo", age: 21, ...>, #<User id: 2, name: "Oscar", age: 21, ...>, #<User id: 5, name: "Foo", age: 23, ...>] def group(*args) - check_empty_arguments("group", args) + has_arguments?("group", args) spawn.group!(*args) end @@ -273,7 +273,7 @@ module ActiveRecord # User.order(:name, email: :desc) # => SELECT "users".* FROM "users" ORDER BY "users"."name" ASC, "users"."email" DESC def order(*args) - check_empty_arguments("order", args) + has_arguments?("order", args) spawn.order!(*args) end @@ -299,7 +299,7 @@ module ActiveRecord # # generates a query with 'ORDER BY name ASC, id ASC'. def reorder(*args) - check_empty_arguments("reorder", args) + has_arguments?("reorder", args) spawn.reorder!(*args) end @@ -322,7 +322,7 @@ module ActiveRecord # User.joins("LEFT JOIN bookmarks ON bookmarks.bookmarkable_type = 'Post' AND bookmarks.user_id = users.id") # => SELECT "users".* FROM "users" LEFT JOIN bookmarks ON bookmarks.bookmarkable_type = 'Post' AND bookmarks.user_id = users.id def joins(*args) - check_empty_arguments("joins", args) + has_arguments?("joins", args) spawn.joins!(*args.compact.flatten) end @@ -935,10 +935,10 @@ module ActiveRecord # passed into that method as an input. For example: # # def references(*args) - # check_empty_arguments("references", args) + # has_arguments?("references", args) # ... # end - def check_empty_arguments(method_name, args) + def has_arguments?(method_name, args) if args.blank? raise ArgumentError, "The method .#{method_name}() must contain arguments." end |