Skip to content

Commit

Permalink
Use private attr_reader
Browse files Browse the repository at this point in the history
Since rails#32028, Rails 6 requires Ruby 2.3+.
No longer needed workaround for Ruby 2.2 "private attribute?" warning.
  • Loading branch information
kamipo committed Feb 23, 2018
1 parent cf629f6 commit 6d63b5e
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def table
tables.first
end

protected
private
attr_reader :alias_tracker
end
end
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/associations/preloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def preloaded_records
owners.flat_map { |owner| owner.association(reflection.name).target }
end

protected
private
attr_reader :owners, :reflection
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ def run(preloader)
end
end

protected
private
attr_reader :owners, :reflection, :preload_scope, :model, :klass

private
# The name of the key on the associated records
def association_key_name
reflection.join_primary_key(klass)
Expand Down
7 changes: 2 additions & 5 deletions activerecord/lib/active_record/attribute_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -432,15 +432,12 @@ def accessed_fields
@attributes.accessed
end

protected

def attribute_method?(attr_name) # :nodoc:
private
def attribute_method?(attr_name)
# We check defined? because Syck calls respond_to? before actually calling initialize.
defined?(@attributes) && @attributes.key?(attr_name)
end

private

def arel_attributes_with_values_for_create(attribute_names)
arel_attributes_with_values(attributes_for_create(attribute_names))
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ def serial?
end
end

protected
private
attr_reader :max_identifier_length

private
def sequence_name_from_parts(table_name, column_name, suffix)
over_length = [table_name, column_name, suffix].map(&:length).sum + 2 - max_identifier_length

Expand Down
4 changes: 1 addition & 3 deletions activerecord/lib/active_record/relation/predicate_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ def build_bind_attribute(column_name, value)
end

protected

attr_reader :table

def expand_from_hash(attributes)
return ["1=0"] if attributes.empty?

Expand Down Expand Up @@ -109,6 +106,7 @@ def expand_from_hash(attributes)
end

private
attr_reader :table

def associated_predicate_builder(association_name)
self.class.new(table.associated_table(association_name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ def call(attribute, value)
array_predicates.inject(&:or)
end

protected

private
attr_reader :predicate_builder

module NullPredicate # :nodoc:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ def call(attribute, value)
predicate_builder.build(attribute, value.id)
end

protected

private
attr_reader :predicate_builder
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ def call(attribute, value)
attribute.eq(bind)
end

protected

private
attr_reader :predicate_builder
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ def call(attribute, value)
end
end

protected

private
attr_reader :predicate_builder
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ def build(opts, other)
WhereClause.new(parts)
end

protected

private
attr_reader :klass, :predicate_builder
end
end
Expand Down
3 changes: 1 addition & 2 deletions activerecord/lib/active_record/statement_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ def self.unsupported_value?(value)
end
end

protected

private
attr_reader :query_builder, :bind_map, :klass
end
end

0 comments on commit 6d63b5e

Please sign in to comment.