Project

General

Profile

Feature #4910

Classes as factories

Added by rklemme (Robert Klemme) about 9 years ago. Updated over 2 years ago.

Status:
Rejected
Priority:
Normal
Target version:
-
[ruby-core:37244]

Description

I suggest to add these two to class Class:

class Class
  alias call new

  def to_proc(*args)
    lambda {|*a| new(*args)}
  end
end

Then we can use class instances where blocks are needed and can easily use them as factory instances using the general contract of #call (see example attached).


Files

pro.rb (836 Bytes) pro.rb Example file with old and new variants rklemme (Robert Klemme), 06/20/2011 08:50 PM

Related issues

Related to Ruby master - Feature #14498: Class#to_procRejectedActions

Also available in: Atom PDF