Actions
Bug #19079
closedModules included in a DelegateClass cannot override delegate methods
Bug #19079:
Modules included in a DelegateClass cannot override delegate methods
Description
Because DelegateClass defines delegate methods on the class itself, those delegate methods come first in the method lookup chain. This prevents included modules from overriding delegate methods:
Base = Class.new do
def foo
"base"
end
end
Helper = Module.new do
def foo
"helper"
end
end
WithHelper = DelegateClass(Base) { include Helper }
WithHelper.new(Base.new).foo
# => "base"
One possible solution would be to define the delegate methods in a separate module. That way, other modules could come before it in the method lookup chain.
Actions