Project

General

Profile

Actions

Bug #13326

closed

Forwarding methods to :method_missing produces a warning

Added by ojab (ojab ojab) almost 8 years ago. Updated almost 8 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:80220]

Description

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

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.

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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0