Project

General

Profile

Actions

Feature #9704

open

Refinements as files instead of modules

Added by trans (Thomas Sawyer) about 8 years ago. Updated over 5 years ago.

Status:
Open
Priority:
Normal
Target version:
-
[ruby-core:61864]

Description

If refinements are to remain file-scoped, then it would be more convenient if using worked at the file level, akin to require, rather than behave like a module include. For instance, instead of:

# foo.rb
module Foo
  refine String do
    def some_method
      ...
    end
  end
end
require 'foo'
using Foo

We could do:

# foo.rb
class String
  def some_method
    ...
  end
end
using 'foo'

This would make require and using, in a certain sense, polymorphic --if we require it will extend the classes directly, but if using then they will be refined instead.


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #12737: Module#defined_refinementsClosedshugo (Shugo Maeda)Actions
Actions

Also available in: Atom PDF