explain why aliasing uses explicit selfs [ci skip]

This commit is contained in:
Xavier Noria 2016-08-08 01:19:32 +02:00
parent a9dc45459a
commit 55dfa00976

@ -65,6 +65,9 @@ def alias_method_chain(target, feature)
# 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