Project

General

Profile

Feature #15842

Allow DelegateClass() to module_eval given block

Added by jeremyevans0 (Jeremy Evans) 4 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
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

Associated revisions

Revision 1cd93f1c
Added by jeremyevans (Jeremy Evans) 4 months ago

Allow DelegateClass() to module_eval given block

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
subclass.

Implements [Feature #15842]

History

Updated by jeremyevans0 (Jeremy Evans) 4 months ago

As delegate.rb is unmaintained, unless someone objects in the next week, I plan on committing this feature.

#2

Updated by jeremyevans (Jeremy Evans) 4 months ago

  • Status changed from Open to Closed

Applied in changeset git|1cd93f1cdfbe6f7e71b05b3f8e707f21d70e94ba.


Allow DelegateClass() to module_eval given block

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
subclass.

Implements [Feature #15842]

Also available in: Atom PDF