Skip to content

Commit

Permalink
Add computed
Browse files Browse the repository at this point in the history
  • Loading branch information
ratierd committed Aug 28, 2020
1 parent 28d8373 commit 18cd18a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions addon/computed.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,24 @@ export function ability(abilityName, resourceName) {
return canService.abilityFor(abilityName, this.get(resourceName));
}).readOnly();
}

export function valueFor(abilityString, model, properties) {
return computed(function() {
let canService = getOwner(this).lookup('service:can');
return canService.valueFor(abilityString, model, properties);
}).readOnly();
}

export function can(abilityString, model, properties) {
return computed(function() {
let canService = getOwner(this).lookup('service:can');
return canService.can(abilityString, model, properties);
}).readOnly();
}

export function cannot(abilityString, model, properties) {
return computed(function() {
let canService = getOwner(this).lookup('service:can');
return canService.cannot(abilityString, model, properties);
}).readOnly();
}

0 comments on commit 18cd18a

Please sign in to comment.