diff --git a/lib/cylon.js b/lib/cylon.js index 7c61e27..edc2d04 100644 --- a/lib/cylon.js +++ b/lib/cylon.js @@ -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; };