aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation.rb
diff options
context:
space:
mode:
authorBogdan Gusiev <agresso@gmail.com>2016-08-16 14:47:11 +0300
committerBogdan Gusiev <agresso@gmail.com>2016-08-23 13:11:06 +0300
commit5b42628e79e85b8697a42f5f566f7cbfd1160847 (patch)
tree10639fdd2aaf84f4bfc382822350db03f5d1dc7d /activerecord/lib/active_record/relation.rb
parent82ec6b36065e91fe0ec5a87f9419840618ce2c5d (diff)
downloadrails-5b42628e79e85b8697a42f5f566f7cbfd1160847.tar.gz
rails-5b42628e79e85b8697a42f5f566f7cbfd1160847.tar.bz2
rails-5b42628e79e85b8697a42f5f566f7cbfd1160847.zip
Remove over meta programming in AR::Relation
Introduced low level methods #set_value and #get_value for setting query attributes: relation.set_value(:where, {id: 1}) relation.get_value(:includes) Used those internally when working with relation's attributes at the abstract level
Diffstat (limited to 'activerecord/lib/active_record/relation.rb')
-rw-r--r--activerecord/lib/active_record/relation.rb13
1 files changed, 4 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 3983065d7a..85b1ddf8db 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -504,15 +504,10 @@ module ActiveRecord
# Post.limit(100).delete_all
# # => ActiveRecord::ActiveRecordError: delete_all doesn't support limit
def delete_all(conditions = nil)
- invalid_methods = INVALID_METHODS_FOR_DELETE_ALL.select { |method|
- if MULTI_VALUE_METHODS.include?(method)
- send("#{method}_values").any?
- elsif SINGLE_VALUE_METHODS.include?(method)
- send("#{method}_value")
- elsif CLAUSE_METHODS.include?(method)
- send("#{method}_clause").any?
- end
- }
+ invalid_methods = INVALID_METHODS_FOR_DELETE_ALL.select do |method|
+ value = get_value(method)
+ SINGLE_VALUE_METHODS.include?(method) ? value : value.any?
+ end
if invalid_methods.any?
raise ActiveRecordError.new("delete_all doesn't support #{invalid_methods.join(', ')}")
end