UNPKG

transit-im

Version:

express-like framework for AIM bots creation (ICQ as well)

64 lines (53 loc) 1.56 kB
// Generated by CoffeeScript 1.6.3 (function() { var Private, _; _ = require('underscore'); Private = (function() { function Private(_knownProperties) { var props, _this = this; this._knownProperties = _knownProperties != null ? _knownProperties : {}; if (_.isArray(this._knownProperties)) { props = this._knownProperties; this._knownProperties = {}; props.forEach(function(p) { return _this.define(p); }); } this._data = {}; } Private.prototype.define = function(property, defValue) { Private.define(this._knownProperties, property); if (!_.isUndefined(defValue)) { return this._data[property] = defValue; } }; Private.define = function(properties, property) { return properties[property] = "defined"; }; Private.prototype.attr = function(name, value) { if (!this._knownProperties[name]) { throw new Error("There is no property with name '" + name + "'"); } if (_.isUndefined(value)) { return this._data[name]; } else { this._data[name] = value; return this; } }; Private.prototype.toJSON = function() { var json, _this = this; json = _.clone(this._data); json._isPrivate = true; json.attr = function(name, value) { _this.attr(name, value); return json[name] = _this.attr(name); }; return json; }; return Private; })(); module.exports = Private; }).call(this);