deep-kernel
Version:
DEEP Kernel Library
78 lines (57 loc) • 2.26 kB
JavaScript
/**
* Created by AlexanderC on 6/10/15.
*/
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Injectable = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _Instance = require('./Instance');
var _deepCore = require('deep-core');
var _deepCore2 = _interopRequireDefault(_deepCore);
var _MissingWorkingMicroserviceException = require('./Exception/MissingWorkingMicroserviceException');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Microservice injectable object
*/
let Injectable = exports.Injectable = function () {
function Injectable() {
_classCallCheck(this, Injectable);
this._microservice = null;
}
/**
* @param {Instance} microservice
* @returns {Injectable}
*/
_createClass(Injectable, [{
key: 'bind',
value: function bind(microservice) {
this.microservice = microservice;
return this;
}
/**
* @returns {Instance}
*/
}, {
key: 'microservice',
get: function get() {
if (this._microservice === null) {
throw new _MissingWorkingMicroserviceException.MissingWorkingMicroserviceException();
}
return this._microservice;
}
/**
* @param {Instance} instance
*/
,
set: function set(instance) {
if (!(instance instanceof _Instance.Instance)) {
throw new _deepCore2.default.Exception.InvalidArgumentException(instance, 'Microservice');
}
this._microservice = instance;
}
}]);
return Injectable;
}();