We all know, that if the target class is composed with modules, you can just call super in a new module. But what if it is an ordinary method in a class?
class Logger
def message(msg)
puts msg
end
end
Say, Logger is a class I can’t change (e.g. it is in a gem).
And I want Logger to put a “================” line before each message. How do I do that in a beauty way? Inheritance? Aggregation? How?
I would either perform subclassing (per @iain’s answer) or a custom module inclusion in your own instances: