Project

General

Profile

Actions

Feature #15842

closed

Allow DelegateClass() to module_eval given block

Added by jeremyevans0 (Jeremy Evans) almost 5 years ago. Updated almost 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:92623]

Description

Methods that return classes often module_eval the given block
(e.g. Class.new and Struct.new). This allows DelegateClass to
work similarly. This makes it easier to use DelegateClass
directly without subclassing, so as not to create an unnecessary
intermediate class. Example:

MyClass = DelegateClass(ClassToDelegateTo) do
  def initialize
    super(obj_of_ClassToDelegateTo)
  end
end

Attached is a patch that implements this proposal.


Files

delegate-class-block.patch (2.26 KB) delegate-class-block.patch jeremyevans0 (Jeremy Evans), 05/11/2019 11:37 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0