Project

General

Profile

Actions

Feature #15326

closed

Proposal: Enable refinements to `#public_send`

Added by osyo (manga osyo) over 5 years ago. Updated over 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:89921]

Description

Sometimes we use #public_send rather than #send to avoid calling the private method.

def meth(a)
  # Not call private method
  # Use #public_send
  a.public_send(a.name)
end

However, #send support to refinements, but #public_send does not support refinements.

class X
  def name
    "hoge"
  end
end

module Ex
  refine X do
    def hoge
      # ...
    end
  end
end

using Ex

def meth(a)
  # Not call private method
  # Use #public_send
  a.public_send(a.name)
end


# Error: undefined method `hoge' for #<X:0x0000561a8cc7e280> (NoMethodError)
meth X.new

#public_send also wants to support refinements.

pull request : https://github.com/ruby/ruby/pull/2019

Actions #1

Updated by nobu (Nobuyoshi Nakada) over 5 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r65919.


Enable refinements to public_send.

[Feature #15326] [Fix GH-2019]

From: manga_osyo

Actions

Also available in: Atom PDF

Like0
Like0