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

Updated by jeremyevans0 (Jeremy Evans) almost 5 years ago

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

Actions #2

Updated by jeremyevans (Jeremy Evans) almost 5 years 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]

Actions

Also available in: Atom PDF

Like0
Like0Like0