-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding computed macros for lazy capability fetching and using them in…
… the identity models
- Loading branch information
Showing
6 changed files
with
49 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities'; | ||
|
||
export default function() { | ||
return lazyCapabilities( | ||
apiPath`identity/${'identityType'}/id/${'id'}`, | ||
'id', | ||
'identityType' | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { queryRecord } from 'ember-computed-query'; | ||
|
||
export function apiPath(strings, ...keys) { | ||
return (function(data) { | ||
let dict = data || {}; | ||
let result = [strings[0]]; | ||
keys.forEach((key, i) => { | ||
result.push(dict[key], strings[i + 1]); | ||
}); | ||
return result.join(''); | ||
}); | ||
}; | ||
|
||
export default function() { | ||
let [templateFn, ...keys] = arguments; | ||
return queryRecord( | ||
'capabilities', | ||
context => { | ||
return { | ||
id: templateFn(context.getProperties(...keys)) | ||
} | ||
}, | ||
...keys | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters