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

doc added for writer method in alias_method_chain[ci skip]

This commit is contained in:
Kuldeep Aggarwal 2014-10-04 18:51:50 +05:30
parent a4d8b62ed1
commit 619f82bf18

View file

@ -19,9 +19,9 @@ class Module
# alias_method :foo_without_feature?, :foo? # alias_method :foo_without_feature?, :foo?
# alias_method :foo?, :foo_with_feature? # alias_method :foo?, :foo_with_feature?
# #
# so you can safely chain foo, foo?, and foo! with the same feature. # so you can safely chain foo, foo?, foo! and/or foo= with the same feature.
def alias_method_chain(target, feature) def alias_method_chain(target, feature)
# Strip out punctuation on predicates or bang methods since # Strip out punctuation on predicates, bang or writer methods since
# e.g. target?_without_feature is not a valid method name. # e.g. target?_without_feature is not a valid method name.
aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1 aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1
yield(aliased_target, punctuation) if block_given? yield(aliased_target, punctuation) if block_given?