-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added engine service share injection utility, as well as minor update…
…s to the universe service
- Loading branch information
Showing
4 changed files
with
34 additions
and
0 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
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,15 @@ | ||
import { getOwner } from '@ember/application'; | ||
|
||
export default function injectEngineService(target, engineName, serviceName, key = null) { | ||
const owner = getOwner(target); | ||
const universe = owner.lookup('service:universe'); | ||
const service = universe.getServiceFromEngine(engineName, serviceName); | ||
const effectiveServiceName = key || serviceName; | ||
|
||
Object.defineProperty(target, effectiveServiceName, { | ||
value: service, | ||
writable: false, | ||
configurable: true, | ||
enumerable: true, | ||
}); | ||
} |
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 @@ | ||
export { default } from '@fleetbase/ember-core/utils/inject-engine-service'; |
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,10 @@ | ||
import injectEngineService from 'dummy/utils/inject-engine-service'; | ||
import { module, test } from 'qunit'; | ||
|
||
module('Unit | Utility | inject-engine-service', function () { | ||
// TODO: Replace this with your real tests. | ||
test('it works', function (assert) { | ||
let result = injectEngineService(); | ||
assert.ok(result); | ||
}); | ||
}); |