Project

General

Profile

Bug #13326

Updated by nobu (Nobuyoshi Nakada) almost 8 years ago

Since 2.4 forwarding methods to private methods is deprecated (https://bugs.ruby-lang.org/issues/12782) and `method_missing` method_missing is private one, so something like 

 ```ruby 
 require 'forwardable' 

 class PostOffice 
   def method_missing(*args); end 
 end 

 class Courier 
   extend Forwardable 

   def_delegators :@post_office, :deliver 

   def initialize 
     @post_office = PostOffice.new 
   end 
 end 

 Courier.new.deliver 
 ``` 
 produces 

 
 ``` 
 /tmp/1.rb:17:in `<main>': Courier#deliver at /Users/ojab/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/forwardable.rb:156 forwarding to private method PostOffice#deliver 
 ``` 

 It's used by shoulda-marchers [for object doubles](https://github.com/thoughtbot/shoulda-matchers/blob/master/lib/shoulda/matchers/doublespeak/object_double.rb). 

 This bug is created to know if such usage is really deprecated depreated and will break in the future or `method_missing` method_missing is a special case that will be supported.

Back