Skip to content

Make it easier to include modules into backend class#538

Open
shioyama wants to merge 5 commits intomasterfrom
backend_methods_included_hook
Open

Make it easier to include modules into backend class#538
shioyama wants to merge 5 commits intomasterfrom
backend_methods_included_hook

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