Skip to content

Commit 8b095c8

Browse files
authored
Merge pull request rails#49021 from Shopify/update-undefine-attribute-methods-docs
[Docs] Update `undefine_attribute_methods` docs
2 parents d70707d + 5bc904d commit 8b095c8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

activemodel/lib/active_model/attribute_methods.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,14 +333,15 @@ def define_attribute_method(attr_name, _owner: generated_attribute_methods)
333333
end
334334
end
335335

336-
# Removes all the previously dynamically defined methods from the class.
336+
# Removes all the previously dynamically defined methods from the class, including alias attribute methods.
337337
#
338338
# class Person
339339
# include ActiveModel::AttributeMethods
340340
#
341341
# attr_accessor :name
342342
# attribute_method_suffix '_short?'
343343
# define_attribute_method :name
344+
# alias_attribute :first_name, :name
344345
#
345346
# private
346347
# def attribute_short?(attr)
@@ -350,11 +351,13 @@ def define_attribute_method(attr_name, _owner: generated_attribute_methods)
350351
#
351352
# person = Person.new
352353
# person.name = 'Bob'
354+
# person.first_name # => "Bob"
353355
# person.name_short? # => true
354356
#
355357
# Person.undefine_attribute_methods
356358
#
357359
# person.name_short? # => NoMethodError
360+
# person.first_name # => NoMethodError
358361
def undefine_attribute_methods
359362
generated_attribute_methods.module_eval do
360363
undef_method(*instance_methods)

0 commit comments

Comments
 (0)