Skip to content

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

@rreinhardt9

Description

@rreinhardt9

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions