Skip to content

Commit

Permalink
Fix method visibility in ActiveRecord::Attributes
Browse files Browse the repository at this point in the history
Follow-up to #44666.

`ActiveRecord::ModelSchema#reload_schema_from_cache` is protected and
`ActiveModel::AttributeRegistration#reset_default_attributes` is
private, so their overrides in `ActiveRecord::Attributes` should match
those visibilities.
  • Loading branch information
jonathanhefner committed Nov 3, 2023
1 parent 296664d commit 2c2ccec
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions activerecord/lib/active_record/attributes.rb
Expand Up @@ -249,12 +249,11 @@ def _default_attributes # :nodoc:
end
end

def reload_schema_from_cache(*)
reset_default_attributes!
super
end

alias :reset_default_attributes :reload_schema_from_cache
protected
def reload_schema_from_cache(*)
reset_default_attributes!
super
end

private
NO_DEFAULT_PROVIDED = Object.new # :nodoc:
Expand All @@ -276,6 +275,10 @@ def define_default_attribute(name, value, type, from_user:)
_default_attributes[name] = default_attribute
end

def reset_default_attributes
reload_schema_from_cache
end

def resolve_type_name(name, **options)
Type.lookup(name, **options, adapter: Type.adapter_name_from(self))
end
Expand Down

0 comments on commit 2c2ccec

Please sign in to comment.