Problem description
Hi 👋
first of all, thank you for this great library! We are currently adding it to our application and are really happy with the framework it provides us with so far. 👍
We noticed that use Permit, permissions_module: MyApp.Permissions introduces a compile-time dependency from our MyApp.Authorization to MyApp.Permissions, which is unfortunate as the latter has quite a few runtime dependencies to schema & context modules of our app, and hence every change to e.g. MyApp.User causes MyApp.Authorization to be recompiled.
It appears that the reason for this compile-time dependency is the way you access the actions_module through the permissions module at compile-time in order to generate a matching set of predicate functions.
|
Macro.expand(permissions_module, __CALLER__).actions_module() |
|
|> Permit.Actions.list_groups() |
Proposed solution
We'd like to ask you to consider removing this compile-time dependency in favor of another explicit actions_module option in Permit.__using__/1. Arguably introduces some redundancy and potential for mismatch between the values given to both modules, but it's a "one-time surprise" type of issue vs. yet another file that needlessly gets recompiled frequently (yes, we used to have a lot of them 🙂 ).
To keep backwards compatibility, you could make it optional and fallback to the access through permissions module:
actions_module =
case Keyword.get(opts, :actions_module) do
nil -> Macro.expand(permissions_module, __CALLER__).actions_module()
module -> Macro.expand(module, __CALLER__)
end
Checklist
[edit] ☝️ actually, this could be related to #23 and/or #24 but not sure
Problem description
Hi 👋
first of all, thank you for this great library! We are currently adding it to our application and are really happy with the framework it provides us with so far. 👍
We noticed that
use Permit, permissions_module: MyApp.Permissionsintroduces a compile-time dependency from ourMyApp.AuthorizationtoMyApp.Permissions, which is unfortunate as the latter has quite a few runtime dependencies to schema & context modules of our app, and hence every change to e.g.MyApp.UsercausesMyApp.Authorizationto be recompiled.It appears that the reason for this compile-time dependency is the way you access the
actions_modulethrough the permissions module at compile-time in order to generate a matching set of predicate functions.permit/lib/permit.ex
Lines 117 to 118 in 4d1c407
Proposed solution
We'd like to ask you to consider removing this compile-time dependency in favor of another explicit
actions_moduleoption inPermit.__using__/1. Arguably introduces some redundancy and potential for mismatch between the values given to both modules, but it's a "one-time surprise" type of issue vs. yet another file that needlessly gets recompiled frequently (yes, we used to have a lot of them 🙂 ).To keep backwards compatibility, you could make it optional and fallback to the access through permissions module:
Checklist
[edit] ☝️ actually, this could be related to #23 and/or #24 but not sure