Ability to pass the name of module to use for an adaptor. Specifically for case where a module contains multiple adaptors
This commit is contained in:
parent
34e562207d
commit
69cc76b6a6
|
@ -262,7 +262,7 @@ Robot.prototype.halt = function() {
|
|||
Robot.prototype.initAdaptor = function(adaptorName, connection, opts) {
|
||||
if (opts == null) { opts = {}; }
|
||||
|
||||
var adaptor = this.robot.requireAdaptor(adaptorName).adaptor({
|
||||
var adaptor = this.robot.requireAdaptor(adaptorName, opts).adaptor({
|
||||
name: adaptorName,
|
||||
connection: connection,
|
||||
extraParams: opts
|
||||
|
@ -285,9 +285,10 @@ Robot.prototype.initAdaptor = function(adaptorName, connection, opts) {
|
|||
// adaptorName - module name of adaptor to require
|
||||
//
|
||||
// Returns the module for the adaptor
|
||||
Robot.prototype.requireAdaptor = function(adaptorName) {
|
||||
Robot.prototype.requireAdaptor = function(adaptorName, opts) {
|
||||
if (this.robot.adaptors[adaptorName] == null) {
|
||||
this.robot.registerAdaptor("cylon-" + adaptorName, adaptorName);
|
||||
var moduleName = opts.module || adaptorName;
|
||||
this.robot.registerAdaptor("cylon-" + moduleName, adaptorName);
|
||||
this.robot.adaptors[adaptorName].register(this);
|
||||
}
|
||||
return this.robot.adaptors[adaptorName];
|
||||
|
|
Loading…
Reference in New Issue