diff options
author | Daniel Schierbeck <dasch@zendesk.com> | 2012-04-12 15:03:19 +0200 |
---|---|---|
committer | Daniel Schierbeck <dasch@zendesk.com> | 2012-04-12 15:03:19 +0200 |
commit | 300868d9cbf52bf268ba81ec289a257f8dc186ae (patch) | |
tree | 35de488dd608310755960a76622dd4cb1d9e3f5c | |
parent | 1d48e5028493b7b628b9e7df0b74a40b44fc1b67 (diff) | |
download | rails-300868d9cbf52bf268ba81ec289a257f8dc186ae.tar.gz rails-300868d9cbf52bf268ba81ec289a257f8dc186ae.tar.bz2 rails-300868d9cbf52bf268ba81ec289a257f8dc186ae.zip |
Remove the addition to the guides
-rw-r--r-- | guides/source/active_support_core_extensions.textile | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/guides/source/active_support_core_extensions.textile b/guides/source/active_support_core_extensions.textile index 181dac72cf..5d0a3f82e8 100644 --- a/guides/source/active_support_core_extensions.textile +++ b/guides/source/active_support_core_extensions.textile @@ -883,26 +883,6 @@ delegate :size, :to => :attachment, :prefix => :avatar In the previous example the macro generates +avatar_size+ rather than +size+. -WARNING: You can only delegate to public methods on the target object. Trying to delegate to a private or protected method will raise a +NoMethodError+ when the delegate is called. - -If you need to delegate to a private or protected method, you will need to implement the delegation method yourself. It's usually rather simple to do using +__send__+: - -<ruby> -class Wrapper - def initialize - # Target#zizzle is a private method. - @target = Target.new - end - - def zizzle(*args, &block) - # __send__ circumvents the private/protected mechanism. - @target.__send__(:zizzle, *args, &block) - end -end -</ruby> - -Since +__send__+ can be used to call private and protected methods, this will not raise a +NoMethodError+. - NOTE: Defined in +active_support/core_ext/module/delegation.rb+ h4. Redefining Methods |