Skip to content
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

Add ability to query if permissions have changed to policies #28

Open
rreinhardt9 opened this issue Oct 11, 2018 · 0 comments
Open

Add ability to query if permissions have changed to policies #28

rreinhardt9 opened this issue Oct 11, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@rreinhardt9
Copy link
Contributor

When calling grant! and revoke! on a policy the return value is always nil. A common paradigm when using accessly might be to grant a permission, and then do one thing if that grant was newly successful and another if it was not.

Since these are "command" methods, I would not advocate that they should return a value that indicates this (such as true or false), but potentially it returns "self" and there is a "query" type method we can then call on the policy to find out if the most recent grant attempt was successful? Then you could write code like:

policy = MyPolicy.new(actor)
policy.grant!(:some_permission)
if policy.permissions_changed?
  do_a_thing
else
  do_another
end

There could be the above method for generic "something has changed" status, and maybe there could also be more specific way to retrieve what changed like:

policy = MyPolicy.new(actor)
policy.grant!(:some_permission)
if policy.permissions_changed.include(:some_permission)
  do_a_thing
else
  do_another
end
@rreinhardt9 rreinhardt9 added the enhancement New feature or request label Oct 11, 2018
@rreinhardt9 rreinhardt9 changed the title Return value of grant! and revoke! is always nil and provides no success information Add ability to query if permissions have changed to policies Oct 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant