Adding `has_attribute?` to ActiveModel::Attributes?

attribute_names was ported from ActiveRecord to ActiveModel::Attributes in #36059, explicitly modeled on the AR counterparts (“along the same lines as the corresponding methods in ActiveRecord::AttributeMethods”). However, has_attribute? was not included:

                 AR    AM
attribute_names   ✓     ✓
has_attribute?    ✓     —

Today the only way to check for a specific attribute in AM is attribute_names.include?("name"), which doesn’t resolve aliases and rebuilds the names array on every call:

class Person
  include ActiveModel::Attributes
  attribute :name, :string
  alias_attribute :full_name, :name
end

Person.attribute_names.include?("full_name") # => false
# AR equivalent: Person.has_attribute?(:full_name) # => true

AR’s has_attribute? handles both, and the AM side already has the same underpinnings (the attribute registry and alias resolution), so the implementation would mirror AR’s at both class and instance level. It’s purely additive and fully backward-compatible. Would this be welcome as a PR?

I’ve just noticed there’s a prior discussion on the same topic: [Feature Proposal] Add method has_attribute? for ActiveModel::AttributeMethods & ::ClassMethods. Apologies for the duplicate — happy to continue the conversation in either thread.