ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "shugo (Shugo Maeda) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "shugo (Shugo Maeda)" <noreply@ruby-lang.org>
Subject: [ruby-core:113778] [Ruby master Feature#12737] Module#defined_refinements
Date: Tue, 06 Jun 2023 12:37:28 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-103427.20230606123728.12@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-12737.20160908053811.12@ruby-lang.org

Issue #12737 has been updated by shugo (Shugo Maeda).


Eregon (Benoit Daloze) wrote in #note-15:
> `Refinement#refined_class` is a bit strange given it can return a module.
> How about adding `Refinement#refined_module` as an alias for clarity?

I'm for it, but it may be better to create another issue.

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

* Author: shugo (Shugo Maeda)
* Status: Closed
* Priority: Normal
* Assignee: shugo (Shugo Maeda)
----------------------------------------
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/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

      parent reply	other threads:[~2023-06-06 12:37 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 ` [ruby-core:106571] " matz (Yukihiro Matsumoto)
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 ` shugo (Shugo Maeda) via ruby-core [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-103427.20230606123728.12@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    --cc=noreply@ruby-lang.org \
    --cc=ruby-core@ml.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).