diff --git a/lib/robot.js b/lib/robot.js index b62ba0c..b672e4a 100644 --- a/lib/robot.js +++ b/lib/robot.js @@ -167,12 +167,7 @@ Robot.prototype.initConnections = function(opts) { if (_.isObject(opts.connections)) { if (_.isArray(opts.connections)) { - str = "Specifying connections as an array is deprecated. "; - str += "It will be removed in 1.0.0."; - - Logger.warn(str); - - this.performArraySetup(opts.connections, "connection"); + this.performArraySetup(opts.connections, "connection", "connections"); return this.connections; } @@ -260,12 +255,7 @@ Robot.prototype.initDevices = function(opts) { if (_.isObject(opts.devices)) { if (_.isArray(opts.devices)) { - str = "Specifying devices as an array is deprecated. "; - str += "It will be removed in 1.0.0."; - - Logger.warn(str); - - this.performArraySetup(opts.devices, "device"); + this.performArraySetup(opts.devices, "device", "devices"); return this.devices; } @@ -414,7 +404,14 @@ Robot.prototype.toString = function() { return "[Robot name='" + this.name + "']"; }; -Robot.prototype.performArraySetup = function(things, typeOfThing) { +Robot.prototype.performArraySetup = function(things, typeOfThing, arrayName) { + var str = "Specifying "; + str += arrayName; + str += " as an array is deprecated. "; + str += "It will be removed in 1.0.0."; + + Logger.warn(str); + _.forEach(things, function(t, key) { var name = _.isString(key) ? key : t.name; this[typeOfThing](name, t);