Permalink
Browse files

Don't expose methods and attrs for internal usage

  • Loading branch information...
kamipo committed Apr 30, 2017
1 parent 5d9d6a4 commit 5734dcd8114cf2958cf4dd40f9402562d7a431fa
@@ -4,8 +4,6 @@ module ActiveRecord
module Associations
# Keeps track of table aliases for ActiveRecord::Associations::JoinDependency
class AliasTracker # :nodoc:
attr_reader :aliases
def self.create(connection, initial_table, type_caster)
aliases = Hash.new(0)
aliases[initial_table] = 1
@@ -80,6 +78,11 @@ def aliased_table_for(table_name, aliased_name)
end
end
# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected
attr_reader :aliases
private
def truncate(name)
@@ -51,11 +51,10 @@ def owner_key_name
raise NotImplementedError
end
def options
reflection.options
end
private
def options
reflection.options
end
def associated_records_by_owner(preloader)
records = load_records do |record|
@@ -3,7 +3,7 @@ module Associations
class Preloader
class BelongsTo < SingularAssociation #:nodoc:
def association_key_name
reflection.options[:primary_key] || klass && klass.primary_key
options[:primary_key] || klass && klass.primary_key
end
def owner_key_name
@@ -65,7 +65,7 @@ def id_to_index_map(ids)
def reset_association(owners, association_name)
should_reset = (through_scope != through_reflection.klass.unscoped) ||
(reflection.options[:source_type] && through_reflection.collection?)
(options[:source_type] && through_reflection.collection?)
# Don't cache the association - we would only be caching a subset
if should_reset
@@ -287,6 +287,11 @@ def get_join_keys(association_klass)
JoinKeys.new(join_pk(association_klass), join_fk)
end
protected
def actual_source_reflection # FIXME: this is a horrible name
self
end
private
def join_pk(_)
@@ -583,12 +588,6 @@ def extensions
Array(options[:extend])
end
protected
def actual_source_reflection # FIXME: this is a horrible name
self
end
private
def calculate_constructable(macro, options)
@@ -761,7 +760,6 @@ def collection?
# Holds all the metadata about a :through association as it was specified
# in the Active Record class.
class ThroughReflection < AbstractReflection #:nodoc:
attr_reader :delegate_reflection
delegate :foreign_key, :foreign_type, :association_foreign_key,
:active_record_primary_key, :type, :get_join_keys, to: :source_reflection
@@ -987,19 +985,23 @@ def add_as_through(seed)
collect_join_reflections(seed + [self])
end
def collect_join_reflections(seed)
a = source_reflection.add_as_source seed
if options[:source_type]
through_reflection.add_as_polymorphic_through self, a
else
through_reflection.add_as_through a
# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected
attr_reader :delegate_reflection
def actual_source_reflection # FIXME: this is a horrible name
source_reflection.actual_source_reflection
end
end
private
def actual_source_reflection # FIXME: this is a horrible name
source_reflection.send(:actual_source_reflection)
def collect_join_reflections(seed)
a = source_reflection.add_as_source seed
if options[:source_type]
through_reflection.add_as_polymorphic_through self, a
else
through_reflection.add_as_through a
end
end
def primary_key(klass)
@@ -1,8 +1,6 @@
module ActiveRecord
class PredicateBuilder
class AssociationQueryValue # :nodoc:
attr_reader :associated_table, :value
def initialize(associated_table, value)
@associated_table = associated_table
@value = value
@@ -12,6 +10,11 @@ def queries
[associated_table.association_foreign_key.to_s => ids]
end
# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected
attr_reader :associated_table, :value
private
def ids
case value
@@ -1,8 +1,6 @@
module ActiveRecord
class PredicateBuilder
class PolymorphicArrayValue # :nodoc:
attr_reader :associated_table, :values
def initialize(associated_table, values)
@associated_table = associated_table
@values = values
@@ -17,6 +15,11 @@ def queries
end
end
# TODO Change this to private once we've dropped Ruby 2.2 support.
# Workaround for Ruby 2.2 "private attribute?" warning.
protected
attr_reader :associated_table, :values
private
def type_to_ids_mapping
default_hash = Hash.new { |hsh, key| hsh[key] = [] }

0 comments on commit 5734dcd

Please sign in to comment.