aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-09-19 06:20:07 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-10-08 00:12:28 +0900
commit0b4cfa2ba3e978386240e0e56a409616cc32fd02 (patch)
tree176a8f6846f832c178680bd56f44ee805e588b04 /activerecord
parent2b5b08b884853b9ec87252d079c7bc81a46931ec (diff)
downloadrails-0b4cfa2ba3e978386240e0e56a409616cc32fd02.tar.gz
rails-0b4cfa2ba3e978386240e0e56a409616cc32fd02.tar.bz2
rails-0b4cfa2ba3e978386240e0e56a409616cc32fd02.zip
Don't expose internal methods in the associations
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/association.rb36
-rw-r--r--activerecord/lib/active_record/associations/has_many_through_association.rb28
2 files changed, 32 insertions, 32 deletions
diff --git a/activerecord/lib/active_record/associations/association.rb b/activerecord/lib/active_record/associations/association.rb
index e4433356e2..4686b9f517 100644
--- a/activerecord/lib/active_record/associations/association.rb
+++ b/activerecord/lib/active_record/associations/association.rb
@@ -79,18 +79,6 @@ module ActiveRecord
target_scope.merge!(association_scope)
end
- # The scope for this association.
- #
- # Note that the association_scope is merged into the target_scope only when the
- # scope method is called. This is because at that point the call may be surrounded
- # by scope.scoping { ... } or with_scope { ... } etc, which affects the scope which
- # actually gets built.
- def association_scope
- if klass
- @association_scope ||= AssociationScope.scope(self)
- end
- end
-
def reset_scope
@association_scope = nil
end
@@ -129,12 +117,6 @@ module ActiveRecord
reflection.klass
end
- # Can be overridden (i.e. in ThroughAssociation) to merge in other scopes (i.e. the
- # through association's scope)
- def target_scope
- AssociationRelation.create(klass, self).merge!(klass.all)
- end
-
def extensions
extensions = klass.default_extensions | reflection.extensions
@@ -195,6 +177,24 @@ module ActiveRecord
end
private
+ # The scope for this association.
+ #
+ # Note that the association_scope is merged into the target_scope only when the
+ # scope method is called. This is because at that point the call may be surrounded
+ # by scope.scoping { ... } or unscoped { ... } etc, which affects the scope which
+ # actually gets built.
+ def association_scope
+ if klass
+ @association_scope ||= AssociationScope.scope(self)
+ end
+ end
+
+ # Can be overridden (i.e. in ThroughAssociation) to merge in other scopes (i.e. the
+ # through association's scope)
+ def target_scope
+ AssociationRelation.create(klass, self).merge!(klass.all)
+ end
+
def scope_for_create
scope.scope_for_create
end
diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb
index 617956c768..f84ac65fa2 100644
--- a/activerecord/lib/active_record/associations/has_many_through_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_through_association.rb
@@ -21,20 +21,6 @@ module ActiveRecord
super
end
- def concat_records(records)
- ensure_not_nested
-
- records = super(records, true)
-
- if owner.new_record? && records
- records.flatten.each do |record|
- build_through_record(record)
- end
- end
-
- records
- end
-
def insert_record(record, validate = true, raise = false)
ensure_not_nested
@@ -48,6 +34,20 @@ module ActiveRecord
end
private
+ def concat_records(records)
+ ensure_not_nested
+
+ records = super(records, true)
+
+ if owner.new_record? && records
+ records.flatten.each do |record|
+ build_through_record(record)
+ end
+ end
+
+ records
+ end
+
# The through record (built with build_record) is temporarily cached
# so that it may be reused if insert_record is subsequently called.
#