class-o-mat
Version:
ALPHA VERSION ONLY: class-o-mats will help to create getter-setter functionality with validations that can be attached to a container class for easier coding. Some basic validations are included. class-o-mats also has the ability to store params as bloc
73 lines (55 loc) • 2.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
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 _bunyan = require('bunyan');
var _bunyan2 = _interopRequireDefault(_bunyan);
var _types = require('../constants/types');
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"); } }
var log = _bunyan2.default.createLogger({ name: "FieldCopier" });
/**
* manages parameters for copying a field to the next
* ClassOMat
*/
var FieldCopier = function () {
function FieldCopier(parent) {
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _types.NONE;
_classCallCheck(this, FieldCopier);
this.TYPE = _types.COPY;
this._params = {
key: key,
parent: parent,
as: key
};
}
_createClass(FieldCopier, [{
key: '$',
value: function $() {
return this._params.parent._addCopiedField(this);
}
}, {
key: 'as',
value: function as() {
var _as = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _types.NONE;
if (_as === _types.NONE) return this._params.as;
this._params.as = _as;
return this;
}
}, {
key: 'as$',
value: function as$() {
var as = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _types.NONE;
return this.as(as).$();
}
}, {
key: 'copyField',
value: function copyField(key) {
return this.$().copyField(key);
}
}]);
return FieldCopier;
}();
exports.default = FieldCopier;
//# sourceMappingURL=field-copier.js.map