/** * Component Object */ var Component = function (config) { this.components = _(config).isArray() ? config : [config]; } Component.prototype.addFeature = function (owner, name) { name = _(name).isArray() ? name : [name]; _(this.components).forEach(function (component) { if ( !component.features ) { component.features = {}; } var path = component.features; path[owner] = path[owner] || []; _(name).forEach(function (newName) { if ( !_(path[owner]).contains(newName) ) { path[owner].push(newName); } }); }); return this; }; /** * Firebird Object */ var Firebird = function (config) { var options = JSON.parse( JSON.stringify(config) ); options.components = {}; _.extend(this, options); }; Firebird.prototype.addComponent = function (id, config) { this.components[id] = _.extend({}, config, { id : id }); return new Component(this.components[id]); };