Reduce perceived complexity of capability computation
This changes the capability computation from code (a very large if statement) to transformation of static data. The data we transform is a map from `ability` to `requirements`: ```ruby { ability_needed: [:test_one?, :test_two?], other_ability: [:test_three?] } ``` If the object passes _any_ of the requirement tests, then it must pass the policy ability check for all of the matched abilities. If the tests are inductive then this becomes a one-to-one reverse mapping, but it need not be, so this formulation can actually express stricter policy tests than the current if statement can (i.e. we can assert that some event needs multiple abilities). This change expresses (like a DSL) the rules as symbols that must be implemented as methods on the receiver, so we need to `send` the requirements to the receiving event.
Showing
Please register or sign in to comment