ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "matz (Yukihiro Matsumoto)" <noreply@ruby-lang.org>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:106571] [Ruby master Feature#12737] Module#defined_refinements
Date: Thu, 09 Dec 2021 07:10:32 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-95233.20211209071032.12@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-12737.20160908053811.12@ruby-lang.org

Issue #12737 has been updated by matz (Yukihiro Matsumoto).


OK, accepted.  After 3.1, you can introduce:

* Module#refinements
* Refinment#refined_class

Matz.


----------------------------------------
Feature #12737: Module#defined_refinements
https://bugs.ruby-lang.org/issues/12737#change-95233

* Author: shugo (Shugo Maeda)
* Status: Assigned
* Priority: Normal
----------------------------------------
How about to provide Module#defined_refinements, which returns the refinements defined in the receiver as a Hash, as follows:

```
module M
  refine String do
    $M_String = self
  end

  refine Integer do
    $M_Integer = self
  end
end

p M.defined_refinements #=> {String => $M_String, Integer => $M_Integer}
```

By `Module#defined_refinements`, you can activate refinements globally:

```
for klass, refinement in M.defined_refinements
  klass.prepend(refinement)
end
```




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

  parent reply	other threads:[~2021-12-09  7:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-12737.20160908053811.12@ruby-lang.org>
2021-10-26  2:21 ` [ruby-core:105796] [Ruby master Feature#12737] Module#defined_refinements shugo (Shugo Maeda)
2021-10-26 19:12 ` [ruby-core:105816] " Eregon (Benoit Daloze)
2021-11-16  4:43 ` [ruby-core:106076] " shugo (Shugo Maeda)
2021-11-16 12:39 ` [ruby-core:106088] " Eregon (Benoit Daloze)
2021-11-18  5:55 ` [ruby-core:106115] " shugo (Shugo Maeda)
2021-11-18  9:40 ` [ruby-core:106128] " Eregon (Benoit Daloze)
2021-11-19  2:01 ` [ruby-core:106164] " shugo (Shugo Maeda)
2021-12-09  7:10 ` matz (Yukihiro Matsumoto) [this message]
2021-12-10  4:43 ` [ruby-core:106612] " shugo (Shugo Maeda)
2023-06-06 12:00 ` [ruby-core:113777] " Eregon (Benoit Daloze) via ruby-core
2023-06-06 12:37 ` [ruby-core:113778] " shugo (Shugo Maeda) via ruby-core

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-95233.20211209071032.12@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).