Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Administrate::Punditize methods as module methods (thoughtbot#2403)
Instead of adding them via `included do`. If they are added via "included do" it makes it hard to override the method in an app's controller. Example: ```ruby module Admin class ApplicationController < Administrate::ApplicationController include Administrate::Punditize def scoped_resource super.where(archived: false) end end end ``` That example will skip pundit completely, because the `def scoped_resource` from `Administrate::Punditize` was added via `included do`, which means it will behave as if we had defined the method twice in `Admin ::ApplicationController`, which will result in the first definition from `Administrate::Punditize` being ignored. And "super" will refer to the no-op definition provided in the base class `Administrate::ApplicationController`. This seems unexpected to me, and makes it hard to add functionality that layers on to pof what `Administrate::Punditize` does. However, if we defined `def scoped_resource` as a module method in `Administrate::Punditize` then `super` in `Admin::ApplicationController` will refer to the method defined in `Administrate::Punditize`.
- Loading branch information