Permalink
Browse files

Renaming the check_empty_arguments method to something more descriptive.

The function is now called has_arguments? so that it's easier to tell
that it's just checking to see if the args are blank or not.
  • Loading branch information...
1 parent 92949d2 commit 7b30cec764d7132b194816f42cc1504a841ce195 @wangjohn wangjohn committed Feb 20, 2013
Showing with 10 additions and 10 deletions.
  1. +10 −10 activerecord/lib/active_record/relation/query_methods.rb
@@ -108,7 +108,7 @@ def create_with_value # :nodoc:
#
# 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
@@ -126,7 +126,7 @@ def includes!(*args) # :nodoc:
# 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
@@ -140,7 +140,7 @@ def eager_load!(*args) # :nodoc:
# 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
@@ -158,7 +158,7 @@ def preload!(*args) # :nodoc:
# 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
@@ -238,7 +238,7 @@ def select!(*fields) # :nodoc:
# 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
@@ -269,7 +269,7 @@ def group!(*args) # :nodoc:
# 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
@@ -295,7 +295,7 @@ def order!(*args) # :nodoc:
#
# 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
@@ -318,7 +318,7 @@ def reorder!(*args) # :nodoc:
# 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
@@ -934,10 +934,10 @@ def validate_order_args(args)
# 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

0 comments on commit 7b30cec

Please sign in to comment.