Skip to content

Commit f705c39

Browse files
author
Gareth Adams
committed
Remove redundant parent method from RESTRICTED_CLASS_METHODS
Previously, `parent` was added as one of the RESTRICTED_CLASS_METHODS as part of a commit (94b7328) in 2014 that stopped Rails `enum`s from being able to redefine important class methods. At the time, Rails monkey-patched `Module` with a `parent` class method that returned a module's containing module if it was nested. However, in October 2020 (167b415) in Rails 6.1, this method was deprecated in favour of a renamed method `module_parent`. As such, the `parent` method doesn't need to be a restricted class method any more.
1 parent 2d6b02b commit f705c39

File tree

3 files changed

+2
-3
lines changed

3 files changed

+2
-3
lines changed

activerecord/lib/active_record/attribute_methods.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module AttributeMethods
2020
include Serialization
2121
end
2222

23-
RESTRICTED_CLASS_METHODS = %w(private public protected allocate new name parent superclass)
23+
RESTRICTED_CLASS_METHODS = %w(private public protected allocate new name superclass)
2424

2525
class GeneratedAttributeMethods < Module # :nodoc:
2626
LOCK = Monitor.new

activerecord/test/cases/enum_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ def self.name; "Book"; end
535535
:save, # generates #save!, which conflicts with an AR method
536536
:proposed, # same value as an existing enum
537537
:public, :private, :protected, # some important methods on Module and Class
538-
:name, :parent, :superclass,
538+
:name, :superclass,
539539
:id # conflicts with AR querying
540540
]
541541

activerecord/test/cases/scoping/named_scoping_test.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ def pro; end
363363
:protected,
364364
:private,
365365
:name,
366-
:parent,
367366
:superclass
368367
]
369368

0 commit comments

Comments
 (0)