Skip to content

Commit 55dfa00

Browse files
committed
explain why aliasing uses explicit selfs [ci skip]
1 parent a9dc454 commit 55dfa00

File tree

1 file changed

+3
-0
lines changed
  • activesupport/lib/active_support/core_ext/module

1 file changed

+3
-0
lines changed

activesupport/lib/active_support/core_ext/module/aliasing.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ def alias_method_chain(target, feature)
6565
# e.subject = "Megastars"
6666
# e.title # => "Megastars"
6767
def alias_attribute(new_name, old_name)
68+
# The following reader methods use an explicit `self` receiver in otder to
69+
# support aliases that start with an uppercase letter. Otherwise, they would
70+
# be resolved as constants instead.
6871
module_eval <<-STR, __FILE__, __LINE__ + 1
6972
def #{new_name}; self.#{old_name}; end # def subject; self.title; end
7073
def #{new_name}?; self.#{old_name}?; end # def subject?; self.title?; end

0 commit comments

Comments
 (0)