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

Make it easier to include modules into backend class #538

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

shioyama
Copy link
Owner

This is a simple change which allows plugins to simply define modules BackendMethods and/or BackendClassMethods and have the backend class auto-include/extend these modules. This simplifies something like this:

module MyPlugin
  extend Mobility::Plugin

  included_hook do |klass, backend_class|
    backend_class.include BackendMethods
    backend_class.extend BackendClassMethods
  end

  module BackendMethods
    # ...
  end

  module BackendClassMethods
    # ...
  end
end

To just this:

module MyPlugin
  extend Mobility::Plugin

  module BackendMethods
    # ...
  end

  module BackendClassMethods
    # ...
  end
end

With this change, if no included hook is defined on a plugin *and* the
plugin defines module(s) named BackendMethods (instance methods) and/or
BackendClassMethods (class methods), a hook is auto-defined to
include/extend those modules from the backend class.
@shioyama shioyama force-pushed the backend_methods_included_hook branch from a7bb8c2 to dc2aedd Compare November 3, 2021 08:53
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

Successfully merging this pull request may close these issues.

1 participant