In Ruby (and even more so: Rails) it is easy to mark methods as deprecated.
But how can I mark an entire class as deprecated? I want to raise a warning whenever a class is used:
class BillingMethod
end
BillingMethod.new #=> DEPRECATION WARNING: the class BillingMethod is deprecated. Use PaymentMethod instead.
Or when it gets used in inheritance:
class Sofort < BillingMethod
end
Sofort.new #=> DEPRECATION WARNING: the class BillingMethod is deprecated. Use PaymentMethod instead.
Or, when used in nested classes:
class BillingMethod::Sofort < BillingMethod
end
BillingMethod::Sofort.new #=> DEPRECATION WARNING: the class BillingMethod is deprecated. Use PaymentMethod instead.
I would think that a class_eval
-block would be the place where to stick such a warning. Is that the correct place? Or are there better methods?