Can I use ActiveSupport::Callbacks methods for a class? More specifically, in the module below, where would you put include ActiveSupport::Callbacks to make define_callbacks and run_callbacks share the same state?
module Handler extend ActiveSupport::Concern # If you put it here, define_callbacks is defined but run_callbacks is not # include ActiveSupport::Callbacks included do class_eval do define_callbacks :handle end end module ClassMethods # If you put it here, run_callbacks is defined but define_callbacks is not # include ActiveSupport::Callbacks def handle(task) run_callbacks :handle do p task end end end end class HandlerExample include Handler end
Update
If this is possible, which I could not install, this, of course, is not what ActiveSupport::Callbacks was designed ActiveSupport::Callbacks . It is best to create an instance object without saving in #handle .
source share