Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ability): split
Ability
into PureAbility
(base class) and `A…
…bility` (preconfigured PureAbility) This should make migration easier and at the same time open more possibilities to configure `Ability` and improves tree shaking support Relates to #249 BREAKING CHANGE: `AbilityBuilder.define` was extracted into `defineAbility` function and `AbilityBuilder.extract` was removed **Before** ```js import { AbilityBuilder, Ability } from '@casl/ability' const ability = AbilityBuilder.define((can) => { can('read', 'Post') }) // the same with extract const { can, rules } = AbilityBuilder.extract() can('read', 'Post') const ability = new Ability(rules) ``` **After** ```js import { defineAbility, Ability, AbilityBuilder } from '@casl/ability' const ability = defineAbility((can) => { can('read', 'Post') }) // the same with constructor const { can, rules } = new AbilityBuilder() can('read', 'Post') const ability = new Ability(rules) ```
- Loading branch information