-
Notifications
You must be signed in to change notification settings - Fork 1
Defining rules for wildcard any subtarget
Adam Pahlevi Baihaqi edited this page Sep 24, 2015
·
2 revisions
Bali also support wildcard subtarget, in addition to definite subtargets.
In this case, Bali provides others
block. Rules defined within definite subtargets are given priority to its others
counterpart, if any.
Bali.map_rules do
rules_for My::Transaction do
describe(:supreme) { can_all }
describe :admin do
can_all
cannot :delete
end
describe :finance do
cannot :view
can :print
end
others do
can :view, if: proc { |txn| txn.is_settled? }
can :print, if: proc { |txn| txn.is_settled? }
can :index
end
end
end
Some that we can deduct from the code above:
- All users, all, nil, supreme, finance, all; can
:index
(returnstrue
) - Finance user cannot
:view
, as rule defined within :finance (which is definite) will nullify its counterpart that is defined inothers
block - Admin, Supreme, Finance user can
:print
, regardless if the transaction is settled or not. - Other users, be it
nil
,:monitoring
, or any subtarget that is not definitely defined will pay respect to theothers
block