#NoMethodsError: super : no superclass method
Closed this issue · 2 comments
gregory commented
require 'dumb_delegator'
class A < DumbDelegator
def bar
'bar'
end
end
class B < DumbDelegator
def bar
"foo" + super
end
end
B.new(A.new("")).bar
=>
#irb(main):002:0> B.new(A.new("")).bar
#NoMethodError: super: no superclass method `bar' for "":B
=>from /usr/local/opt/rbenv/versions/1.9.3-p327-perf/gemsets/rmo/gems/dumb_delegator-0.5.1/lib/d>
gregory commented
This fixes the "issue" but just wanna highlight that it can be confusing ...
class B < DumbDelegator
def bar
"foo" + getobj.bar
end
end
stevenharman commented
Right, that makes sense as the delegated object is not in the ancestor chain foe the subclass. But a good, tricky, catch. Thanks.