keruilin
keruilin

Reputation: 17512

Subclasses using any methods from base class module includes?

Let's say I have a base class called Stream and a bunch of subclasses of Stream.

class Stream

  include DateTimeHelper
  include LinkHelper
  include FormatHelper

  def ...
    ...
  end

end

class LongStream < Stream

  def ...
    ...
  end

end

So the subclasses here have access to whatever methods are in the include modules.

There's a chance based on history of refactoring that none of classes in the hierarchy use any methods from FormatHelper, for example. Is there any way for me to programmatically inspect whether or not any of the module's methods are being used?

Upvotes: 0

Views: 573

Answers (1)

buruzaemon
buruzaemon

Reputation: 3907

You could replace or enhance the modules' methods using alias_method, to add logging when that module's methods are invoked, for example.

Upvotes: 1

Related Questions