Simplify Master#api

This commit is contained in:
Andrew Stewart 2014-04-21 16:36:47 -07:00
parent 801d1a5d49
commit e66c1145d5
1 changed files with 7 additions and 14 deletions

View File

@ -101,21 +101,14 @@ var Cylon = (function() {
Master.prototype.api = function(opts) {
if (opts == null) { opts = {}; }
var host = opts.host || this.api_config.host,
port = opts.port || this.api_config.port,
auth = opts.auth || this.api_config.auth,
cert = opts.cert || this.api_config.cert,
cors = opts.CORS || this.api_config.CORS,
key = opts.key || this.api_config.key;
var keys = ['host', 'port', 'auth', 'cert', 'CORS', 'key'];
this.api_config = {
host: host,
port: port,
cert: cert,
key: key,
auth: auth,
CORS: cors
};
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (typeof opts[key] !== "undefined") {
this.api_config[key] = opts[key];
}
}
return this.api_config;
};