ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: manga.osyo@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:91484] [Ruby trunk Feature#15374] Proposal: Enable refinements to `#method_missing`
Date: Fri, 08 Feb 2019 00:02:54 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-76743.20190208000253.83f4fd3ce855c939@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15374.20181203110716@ruby-lang.org

Issue #15374 has been updated by osyo (manga osyo).


OK, Thanks matz :)

----------------------------------------
Feature #15374: Proposal: Enable refinements to `#method_missing`
https://bugs.ruby-lang.org/issues/15374#change-76743

* Author: osyo (manga osyo)
* Status: Rejected
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Proposal enable refinements to `#method_missing`.
It can be used in the following cases.

```ruby
# Access key value with method
using Module.new {
	refine Hash do
		# name is Symbol or String
		def method_missing(name)
			self[name.to_sym] || self[name.to_s]
		end
	end
}

hash = { name: "homu", "age" => 14 }
pp hash.name
# => "homu"
pp hash.age
# => "age"
```

`method_missing` is hard hacking.
I would like to use Refinements with `method_missing`.

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




-- 
https://bugs.ruby-lang.org/

      parent reply	other threads:[~2019-02-08  0:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-15374.20181203110716@ruby-lang.org>
2018-12-03 11:07 ` [ruby-core:90258] [Ruby trunk Feature#15374] Proposal: Enable refinements to `#method_missing` manga.osyo
2018-12-03 15:29 ` [ruby-core:90265] " hanmac
2018-12-04 11:22 ` [ruby-core:90283] " manga.osyo
2019-02-06 19:54 ` [ruby-core:91442] " eregontp
2019-02-07  4:13 ` [ruby-core:91446] " manga.osyo
2019-02-07  7:59 ` [ruby-core:91464] " matz
2019-02-08  0:02 ` manga.osyo [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-76743.20190208000253.83f4fd3ce855c939@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).