Permalink
Browse files

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

…graph

Clarify docs for delegate :allow_nil option
  • Loading branch information...
eileencodes committed Dec 18, 2017
2 parents b2be83f + c46c303 commit 6553c7fef702331c47001e1003067fd555aa7ccd
Showing with 2 additions and 5 deletions.
  1. +2 −5 activesupport/lib/active_support/core_ext/module/delegation.rb
@@ -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

0 comments on commit 6553c7f

Please sign in to comment.