1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Module#attr_reader/writer are public methods since Ruby 2.5

This commit is contained in:
Akira Matsuda 2020-10-27 00:54:12 +09:00
parent b37473ebbd
commit 1f86a17031

View file

@ -30,7 +30,7 @@ class Module
def attr_internal_define(attr_name, type) def attr_internal_define(attr_name, type)
internal_name = attr_internal_ivar_name(attr_name).delete_prefix("@") internal_name = attr_internal_ivar_name(attr_name).delete_prefix("@")
# use native attr_* methods as they are faster on some Ruby implementations # use native attr_* methods as they are faster on some Ruby implementations
send("attr_#{type}", internal_name) public_send("attr_#{type}", internal_name)
attr_name, internal_name = "#{attr_name}=", "#{internal_name}=" if type == :writer attr_name, internal_name = "#{attr_name}=", "#{internal_name}=" if type == :writer
alias_method attr_name, internal_name alias_method attr_name, internal_name
remove_method internal_name remove_method internal_name