Project

General

Profile

Actions

Feature #4910

closed

Classes as factories

Added by rklemme (Robert Klemme) over 13 years ago. Updated almost 7 years ago.

Status:
Rejected
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 1 (0 open1 closed)

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

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0