Skip to content

Commit

Permalink
Ensure type_for_attribute method docs are visible [ci-skip]
Browse files Browse the repository at this point in the history
`ActiveModel::AttributeRegistration` is marked `:nodoc:`, so
`type_for_attribute` must be documented under `ActiveModel::Attributes`,
which includes `ActiveModel::AttributeRegistration`.

Also, RDoc does not correctly interpret `:method:` docs when they are
immediately followed by a visibility keyword.  Therefore, this commit
adds delimiter comments before the keywords, similar to
4726b1a.
  • Loading branch information
jonathanhefner committed Jan 7, 2024
1 parent b294a25 commit 2945608
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
5 changes: 0 additions & 5 deletions activemodel/lib/active_model/attribute_registration.rb
Expand Up @@ -40,11 +40,6 @@ def attribute_types # :nodoc:
end
end

# Returns the type of the specified attribute after applying any
# modifiers. This method is the only valid source of information for
# anything related to the types of a model's attributes. The return value
# of this method will implement the interface described by
# ActiveModel::Type::Value (though the object itself may not subclass it).
def type_for_attribute(attribute_name, &block)
attribute_name = resolve_attribute_name(attribute_name)

Expand Down
13 changes: 13 additions & 0 deletions activemodel/lib/active_model/attributes.rb
Expand Up @@ -75,6 +75,19 @@ def attribute_names
attribute_types.keys
end

##
# :method: type_for_attribute
# :call-seq: type_for_attribute(attribute_name, &block)
#
# Returns the type of the specified attribute after applying any
# modifiers. This method is the only valid source of information for
# anything related to the types of a model's attributes. The return value
# of this method will implement the interface described by
# ActiveModel::Type::Value (though the object itself may not subclass it).
#--
# Implemented by ActiveModel::AttributeRegistration::ClassMethods#type_for_attribute.

##
private
def define_method_attribute=(name, owner:)
ActiveModel::AttributeMethods::AttrNames.define_attribute_accessor_method(
Expand Down
5 changes: 4 additions & 1 deletion activerecord/lib/active_record/attributes.rb
Expand Up @@ -253,11 +253,14 @@ def _default_attributes # :nodoc:
# :method: type_for_attribute
# :call-seq: type_for_attribute(attribute_name, &block)
#
# See ActiveModel::AttributeRegistration::ClassMethods#type_for_attribute.
# See ActiveModel::Attributes::ClassMethods#type_for_attribute.
#
# This method will access the database and load the model's schema if
# necessary.
#--
# Implemented by ActiveModel::AttributeRegistration::ClassMethods#type_for_attribute.

##
protected
def reload_schema_from_cache(*)
reset_default_attributes!
Expand Down

0 comments on commit 2945608

Please sign in to comment.