Extract even more of function to DRY up code
This commit is contained in:
parent
5cea07602a
commit
6ac3cad7c1
23
lib/robot.js
23
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);
|
||||
|
|
Loading…
Reference in New Issue