Namespace all the adaptors

This commit is contained in:
deadprogram 2013-10-25 13:01:18 -07:00
parent 69a476dfbf
commit 7a67dbfd22
3 changed files with 46 additions and 40 deletions

54
dist/loopback.js vendored
View File

@ -1,5 +1,5 @@
/*
* adaptor
* Loopback adaptor
* cylonjs.com
*
* Copyright (c) 2013 The Hybrid Group
@ -9,38 +9,44 @@
(function() {
'use strict';
var Loopback;
var Adaptor, Loopback,
__slice = [].slice;
module.exports = {
adaptor: function(opts) {
if (opts == null) {
opts = {};
}
return new Loopback(opts);
adaptor: function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return (function(func, args, ctor) {
ctor.prototype = func.prototype;
var child = new ctor, result = func.apply(child, args);
return Object(result) === result ? result : child;
})(Adaptor.Loopback, args, function(){});
}
};
Loopback = (function() {
function Loopback(opts) {
this.self = this;
this.name = opts.name;
}
Adaptor = {
Loopback: Loopback = (function() {
function Loopback(opts) {
this.self = this;
this.name = opts.name;
}
Loopback.prototype.connect = function() {
Logger.info("Connecting to adaptor '" + this.name + "'...");
return this.self;
};
Loopback.prototype.connect = function() {
Logger.info("Connecting to adaptor '" + this.name + "'...");
return this.self;
};
Loopback.prototype.disconnect = function() {
return Logger.info("Disconnecting from adaptor '" + this.name + "'...");
};
Loopback.prototype.disconnect = function() {
return Logger.info("Disconnecting from adaptor '" + this.name + "'...");
};
Loopback.prototype.commands = function() {
return ['ping'];
};
Loopback.prototype.commands = function() {
return ['ping'];
};
return Loopback;
return Loopback;
})();
})()
};
}).call(this);

View File

@ -8,8 +8,7 @@ bots = [
class ChattyRobot
connection:
name: 'loopback'
adaptor: 'loopback'
name: 'loopback', adaptor: 'loopback'
work: (me) ->
every 1.seconds(), ->

View File

@ -1,5 +1,5 @@
###
* adaptor
* Loopback adaptor
* cylonjs.com
*
* Copyright (c) 2013 The Hybrid Group
@ -9,20 +9,21 @@
'use strict';
module.exports =
adaptor: (opts = {}) ->
new Loopback(opts)
adaptor: (args...) ->
new Adaptor.Loopback(args...)
class Loopback
constructor: (opts) ->
@self = this
@name = opts.name
Adaptor =
Loopback: class Loopback
constructor: (opts) ->
@self = this
@name = opts.name
connect: ->
Logger.info "Connecting to adaptor '#{@name}'..."
@self
connect: ->
Logger.info "Connecting to adaptor '#{@name}'..."
@self
disconnect: ->
Logger.info "Disconnecting from adaptor '#{@name}'..."
disconnect: ->
Logger.info "Disconnecting from adaptor '#{@name}'..."
commands: ->
['ping']
commands: ->
['ping']