Let's say I have a hypothetical gem, my_gem
, that defines the class AwesomeClass
, and the gem includes a binary that will only work on AwesomeClass
, but will load any code in my lib/
directory, say. I want to cleanly extend some of the class' methods, sometimes calling the equivalent of super
.
Let's say it looks like this:
class AwesomeClass
def cool_method
...
end
end
And over here, in my library code, I want to do something like:
AwesomeClass.class_eval
def cool_method
(call the original method here)
...
end
end
How would you do that? Is alias
my only real option? Is there some nicer way I'm missing? Something other than class_eval
?