diff --git a/src/device.coffee b/src/device.coffee index ba4a1e0..5b2ccd7 100644 --- a/src/device.coffee +++ b/src/device.coffee @@ -9,10 +9,20 @@ 'use strict'; module.exports = class Device - constructor: (opts) -> + constructor: (opts = {}) -> + @parent = opts.parent @name = opts.name - @driver = opts.driver + @connection = @determineConnection(opts.connection) or @defaultConnection + @driver = @requireDriver(opts.driver) start: -> console.log "started" - \ No newline at end of file + + determineConnection: (c) -> + @parent.connections(c) if c + + defaultConnection: -> + @parent.connections.first + + requireDriver: (driverName) -> + console.log "dynamic load driver" diff --git a/test/src/specs/device.spec.coffee b/test/src/specs/device.spec.coffee index 1e23abe..7315041 100644 --- a/test/src/specs/device.spec.coffee +++ b/test/src/specs/device.spec.coffee @@ -8,7 +8,5 @@ describe "devices", -> it "should have a name", -> device.name.should.be.equal 'devisive' - it "should have an driver", -> - device.driver.should.be.equal 'driving' - - it "should be able to require an external driver module" + it "should have a connection" + it "should have an driver"