-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
docs: add alternative ways to write a policy #1513
Conversation
end | ||
``` | ||
|
||
#### Policy with multiple conditions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if it is the right place to mention multiple conditions for one policy.
|
||
```elixir | ||
policies do | ||
policy [condition1, condition2, condition3] do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be sufficient to change the original introduction of checks to contain the list example, which I mentioned above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will remove it.
|
||
```elixir | ||
policies do | ||
policy always(), authorize_if: always() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I worry a bit about adding confusion for these various syntaxes. There isn't really any good reason for someone to have to know that you can use this keyword list syntax. The do
block syntax is preferable. I think better to leave this out here, or at the very least put this at the bottom.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I did not know there was a preference toward do
block. I will remove it.
In my personal project, I was using mostly the keyword list variant, because I find it easier to read. Also it reduce some lines.
``` | ||
|
||
#### Policy with `condition` inside `do` block | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add some explanation here. Like why they might want to specify the condition this way.
Putting the condition inside the policy block can make really long condition lists easier to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added some explanation.
Co-authored-by: Zach Daniel <zachary.s.daniel@gmail.com>
@zachdaniel Thanks for the feedback. I have made the requested changes. Could you please have a look again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Thank you for your contribution! 🚀
Contributor checklist