UNPKG

1.89 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _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; }; }();
8
9var _clone = require('clone');
10
11var _clone2 = _interopRequireDefault(_clone);
12
13function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16
17var RuleResult = function () {
18 function RuleResult(conditions, event, priority) {
19 _classCallCheck(this, RuleResult);
20
21 this.conditions = (0, _clone2.default)(conditions);
22 this.event = (0, _clone2.default)(event);
23 this.priority = (0, _clone2.default)(priority);
24 this.result = null;
25 }
26
27 _createClass(RuleResult, [{
28 key: 'setResult',
29 value: function setResult(result) {
30 this.result = result;
31 }
32 }, {
33 key: 'toJSON',
34 value: function toJSON() {
35 var stringify = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
36
37 var props = {
38 conditions: this.conditions.toJSON(false),
39 event: this.event,
40 priority: this.priority,
41 result: this.result
42 };
43 if (stringify) {
44 return JSON.stringify(props);
45 }
46 return props;
47 }
48 }]);
49
50 return RuleResult;
51}();
52
53exports.default = RuleResult;
\No newline at end of file