diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2013-04-25 19:45:41 -0700 |
---|---|---|
committer | Guillermo Iguaran <guilleiguaran@gmail.com> | 2013-04-25 19:45:41 -0700 |
commit | 23b6e9d85d4a57ab0a24ae5e03965ff6c8de5bca (patch) | |
tree | 687a3ab3a44578ebd11772c68e06fcc6d4699df6 /activesupport/lib | |
parent | d495606168f638b272f5775b2a0a796f13ab7c1b (diff) | |
parent | ccbe02343934956d3bb11c7167e0493f9d8f08fd (diff) | |
download | rails-23b6e9d85d4a57ab0a24ae5e03965ff6c8de5bca.tar.gz rails-23b6e9d85d4a57ab0a24ae5e03965ff6c8de5bca.tar.bz2 rails-23b6e9d85d4a57ab0a24ae5e03965ff6c8de5bca.zip |
Merge pull request #10347 from lellisga/delegation_bug_documentation
Delegation method bug
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/module/delegation.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb index e608eeaf42..c0828343d8 100644 --- a/activesupport/lib/active_support/core_ext/module/delegation.rb +++ b/activesupport/lib/active_support/core_ext/module/delegation.rb @@ -112,6 +112,20 @@ class Module # end # # Foo.new.zoo # returns nil + # + # If the delegate object is not +nil+ or +false+ and the object doesn't + # respond to the delegated method it will raise an exception. + # + # class Foo + # def initialize(bar) + # @bar = bar + # end + # + # delegate :name, to: :@bar + # end + # + # Foo.new("Bar").name # raises NoMethodError: undefined method `name' + # def delegate(*methods) options = methods.pop unless options.is_a?(Hash) && to = options[:to] |