mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Get rid of separate reset_target! and reset_scopes_cache! methods
This commit is contained in:
@@ -50,9 +50,9 @@ module ActiveRecord
|
||||
alias_method :to_a, :to_ary
|
||||
|
||||
def reset
|
||||
reset_target!
|
||||
reset_scopes_cache!
|
||||
@loaded = false
|
||||
@_scopes_cache = {}
|
||||
@loaded = false
|
||||
@target = []
|
||||
end
|
||||
|
||||
def build(attributes = {}, &block)
|
||||
@@ -106,10 +106,20 @@ module ActiveRecord
|
||||
#
|
||||
# See delete for more info.
|
||||
def delete_all
|
||||
load_target
|
||||
delete(@target)
|
||||
reset_target!
|
||||
reset_scopes_cache!
|
||||
delete(load_target).tap do
|
||||
reset
|
||||
loaded!
|
||||
end
|
||||
end
|
||||
|
||||
# Destroy all the records from this association.
|
||||
#
|
||||
# See destroy for more info.
|
||||
def destroy_all
|
||||
destroy(load_target).tap do
|
||||
reset
|
||||
loaded!
|
||||
end
|
||||
end
|
||||
|
||||
# Calculate sum using SQL, not Enumerable
|
||||
@@ -194,17 +204,6 @@ module ActiveRecord
|
||||
self
|
||||
end
|
||||
|
||||
# Destroy all the records from this association.
|
||||
#
|
||||
# See destroy for more info.
|
||||
def destroy_all
|
||||
load_target
|
||||
destroy(@target).tap do
|
||||
reset_target!
|
||||
reset_scopes_cache!
|
||||
end
|
||||
end
|
||||
|
||||
def create(attrs = {})
|
||||
if attrs.is_a?(Array)
|
||||
attrs.collect { |attr| create(attr) }
|
||||
@@ -395,14 +394,6 @@ module ActiveRecord
|
||||
interpolate_sql(@reflection.options[:finder_sql])
|
||||
end
|
||||
|
||||
def reset_target!
|
||||
@target = []
|
||||
end
|
||||
|
||||
def reset_scopes_cache!
|
||||
@_scopes_cache = {}
|
||||
end
|
||||
|
||||
def find_target
|
||||
records =
|
||||
if @reflection.options[:finder_sql]
|
||||
|
||||
Reference in New Issue
Block a user