Merge pull request #31479 from iamvery/reword-delegate-allow-nil-paragraph

Clarify docs for delegate :allow_nil option
This commit is contained in:
Eileen M. Uchitelle 2017-12-18 10:01:32 -05:00 committed by GitHub
commit 6553c7fef7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -115,11 +115,8 @@ class DelegationError < NoMethodError; end
# invoice.customer_address # => 'Vimmersvej 13'
#
# If the target is +nil+ and does not respond to the delegated method a
# +Module::DelegationError+ is raised, as with any other value. Sometimes,
# however, it makes sense to be robust to that situation and that is the
# purpose of the <tt>:allow_nil</tt> option: If the target is not +nil+, or it
# is and responds to the method, everything works as usual. But if it is +nil+
# and does not respond to the delegated method, +nil+ is returned.
# +Module::DelegationError+ is raised. If you wish to instead return +nil+,
# use the <tt>:allow_nil</tt> option.
#
# class User < ActiveRecord::Base
# has_one :profile