R
Robert Klemme
trans. (T. Onoma) said:Here's one related to a recent thread:
class Object
def supers(klass=self.class.superclass)
raise ArgumentError if ! self.class.ancestors.include?(klass)
Functor.new do |meth, *args|
klass.instance_method(meth).bind(self).call(*args)
end
end
end
Hmm, maybe should cache the functor for efficiency.
Might not be a good idea since the method can change. Currently I don't know
a way to detect that change as those method methods always return new
instances.
Apart from that I still think that explicit super class method invocation
other than a method invocing its own super implementation is a code smell
that indicates the need for a refactoring.
Cheers
robert