Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding callbacks to a base class #21

Open
iconnor opened this issue May 12, 2016 · 0 comments
Open

Adding callbacks to a base class #21

iconnor opened this issue May 12, 2016 · 0 comments

Comments

@iconnor
Copy link

iconnor commented May 12, 2016

If you add the before_start and other callbacks to a base class, then inherit that to a worker, it will not trigger the callbacks.

You have to prepend Sqeduler::Worker::Callbacks on each child class. It would be nice to have it work on the base class also so we can reduce duplication.

There is a work around: that is to prepend and then include the before_start and other callbacks from a module.

So this:

class AwardWorker < BaseWorker
  prepend Sqeduler::Worker::Callbacks
  include Logging::Callbacks
etc. for each class

Instead of this just once:

class BaseWorker
  prepend Sqeduler::Worker::Callbacks
  include Logging::Callbacks

Logging::Callbacks is where the private method before_start is found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant