diff options
author | Xavier Noria <fxn@hashref.com> | 2016-08-08 01:19:32 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2016-08-08 01:19:32 +0200 |
commit | 55dfa009769962367c58563480c9f776ae0f53ea (patch) | |
tree | de15e2841dc0ac60da971dd8d4305c9c7e5f1761 /activesupport/lib | |
parent | a9dc45459abcd9437085f4dd0aa3c9d0e64e062f (diff) | |
download | rails-55dfa009769962367c58563480c9f776ae0f53ea.tar.gz rails-55dfa009769962367c58563480c9f776ae0f53ea.tar.bz2 rails-55dfa009769962367c58563480c9f776ae0f53ea.zip |
explain why aliasing uses explicit selfs [ci skip]
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/module/aliasing.rb | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/aliasing.rb b/activesupport/lib/active_support/core_ext/module/aliasing.rb index 83b94aa3cc..ccc4b0db3a 100644 --- a/activesupport/lib/active_support/core_ext/module/aliasing.rb +++ b/activesupport/lib/active_support/core_ext/module/aliasing.rb @@ -65,6 +65,9 @@ class Module # e.subject = "Megastars" # e.title # => "Megastars" def alias_attribute(new_name, old_name) + # The following reader methods use an explicit `self` receiver in otder to + # support aliases that start with an uppercase letter. Otherwise, they would + # be resolved as constants instead. module_eval <<-STR, __FILE__, __LINE__ + 1 def #{new_name}; self.#{old_name}; end # def subject; self.title; end def #{new_name}?; self.#{old_name}?; end # def subject?; self.title?; end |