Overview
Reading the code of Pundit.
Preparation
- Clone the Pundit repository
git clone git@github.com:varvet/pundit.git
Code Reading
Let's take a look at the authorize method used when applying permissions.
- authorize
- varvet/pundit/blob/main/lib/pundit.rb#L75
- Defined as a class method of the module
- varvet/pundit/blob/main/lib/pundit/context.rb#L55
- The actual processing is done in the
authorizemethod of thePundit::Contextclass - Here, the policy is checked, and permissions are determined.
- The actual processing is done in the
The implementation was surprisingly simple.