Clarify docs for delegate :allow_nil option

This commit is contained in:
Jay Hayes 2017-12-15 14:32:52 -06:00
parent 6bd28902e2
commit c46c303c86

@ -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