Project

General

Profile

Actions

Feature #16241

open

Shorter syntax for anonymous refinements

Added by palkan (Vladimir Dementyev) about 5 years ago. Updated about 4 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:95234]

Description

The original discussion is here https://bugs.ruby-lang.org/issues/14344.

tl;dr

  • Refinements are often used in-place with anonymous modules
  • Having shorter syntax could lower the barrier of entry for Rubyist wanting to explore this feature
  • Previous syntax suggestions were not accepted.

I suggest adding a shorter syntax (technically, API):

# before
using(Module.new do
  refine Array do
    def foo;"bar";end
  end
end)

# after
refining Array do
  def foo; "bar"; end
end

The original idea was to use using_refined instead of refining but after discussing with Matz we decided that it's too verbose, and refining seems better. But is it good enough? Any thoughts?


Related issues 3 (0 open3 closed)

Related to Ruby master - Feature #14344: refine at class levelRejectedActions
Related to Ruby master - Feature #11919: Passing a module directly RejectedActions
Has duplicate Ruby master - Feature #17336: using refined: do ... endClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0