/* global conjur, async */ (function(conjur, async, errback) { 'use strict'; var Generic = this.Generic; var Policy = this.Policy = function(args) { if (!(this instanceof Policy)) { return new Policy(args); } var superArguments = Array.prototype.slice.call(arguments); superArguments.unshift('policy'); Generic.apply(this, superArguments); return undefined; }; Policy.prototype = Object.create(Generic.prototype); Policy.prototype.constructor = Policy; Policy.prototype.fetch = function(callback, customErrback) { if (typeof(customErrback) === 'undefined') { customErrback = errback; // reset to default } async.parallel([ this.resource.bind(this), this.ownedResources.bind(this), this.allRoles.bind(this) ], function(err, results) { if (err) { return customErrback(err.status); } callback({ policy: results[0], owned: results[1], roles: results[2], annotations: results[0].annotations, owner: results[0].owner }); return undefined; }); }; }).bind(conjur.models.Record) ( conjur, async, conjur.utils.errback );