Project

General

Profile

Feature #15326

Proposal: Enable refinements to `#public_send`

Added by osyo (manga osyo) 22 days ago. Updated 21 days ago.

Status:
Closed
Priority:
Normal
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

Associated revisions

Revision 633fef6d
Added by nobu (Nobuyoshi Nakada) 21 days ago

Enable refinements to public_send.

[Feature #15326] [Fix GH-2019]

From: manga_osyo manga.osyo@gmail.com

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 65919
Added by nobu (Nobuyoshi Nakada) 21 days ago

Enable refinements to public_send.

[Feature #15326] [Fix GH-2019]

From: manga_osyo manga.osyo@gmail.com

History

#1 Updated by nobu (Nobuyoshi Nakada) 21 days 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 manga.osyo@gmail.com

Also available in: Atom PDF