Project

General

Profile

Actions

Feature #14344

closed

refine at class level

Added by kddnewton (Kevin Newton) almost 7 years ago. Updated almost 6 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:84778]

Description

I rely on refinements a lot, but don't want to keep writing Module.new in code. I'm proposing Object::refine, which would create an anonymous module behind the scenes with equivalent functionality. So:

class Test
  using Module.new {
    refine String do
      def refined?
        true
      end
    end
  }
end

would become

class Test
  refine String do
    def refined?
      true
    end
  end
end

It's a small change, but reads a lot more clearly. Thoughts?


Related issues 2 (1 open1 closed)

Related to Ruby master - Feature #16241: Shorter syntax for anonymous refinementsOpenActions
Related to Ruby master - Feature #11919: Passing a module directly RejectedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0