   
     @param dataSource [DataSource] The data source instance
   ###
-  constructor: (dataSource) ->
-    console.log 'constructor'
-    Connector.call this, 'arangodb', dataSource.settings
+  constructor: (settings, dataSource) ->
+    console.log 'constructor called'
+    super 'arangodb', settings
+    
+    # link to datasource
     @dataSource = dataSource
-    @dataSource.connector = this
     
-    settings = dataSource.settings or {}
-    @settings = settings
+    # debug
+    @debug = dataSource.settings.debug or debug.enabled
     
-    @name = 'arangodb'
-    @_models = {}
-    
-    @arangoConfig = connectionConfig @settings
+    # Query builder
     @qb = require('aqb')
     
-    return this
-  
+    @db = require('arangojs') @settings
+    @api = @db.route '_api'
   
   # one file per functionality
-  @extend require('./core')
-  @extend require('./crud')
-  @extend require('./migration')
+  @extend require('./CoreMixin')
+  @extend require('./CrudMixin')
+  @extend require('./MigrationMixin')
 
-require('util').inherits ArangoDBConnector, Connector
+# require('util').inherits ArangoDBConnector, Connector
 
 exports.ArangoDBConnector = ArangoDBConnector
    obj.included?.apply(@)
    this
  
  @optimizeSettings: (settings) ->
    # settings is a string, dsn coded e.g. http://localhost:8529/ConnectorTest
    if typeof settings is 'string'
      url_obj = url.parse settings
    
      
      database = url_obj.pathname[1..].split('/')[0]
      delete url_obj.path
      delete url_obj.pathname
      url_obj.protocol = 'http:'
      url_obj.slashes = true
    
      url = url.format url_obj
      databaseName = database
    else
      user = settings.user or settings.username or null
      pass = settings.pass or settings.password or null
      auth = if user and pass then "#{user}:#{pass}" else null
    
      host = settings.host or 'localhost'
      port = settings.port or 8529
      hostname = "#{host}:#{port}"
    
      url = if auth? then "http://#{auth}@#{hostname}" else "http://#{hostname}"
      database = settings.database or settings.db or '_system'
      
    
    return {
      url: url
      databaseName: database
      promise: false
    }
  
  
  
  
  ###
    The constructor for ArangoDB connector

    @param dataSource [Object] Object to connect this connector to a data source
    @option settings host [String] The host/ip address to connect with

  @param callback [Function] The callback function
###
exports.initialize = (dataSource, callback) ->
  return if not ajs?
  dataSource.driver = ajs;
  
  settings = generateArangoDBObject dataSource.settings
  
  dataSource.connector = new ArangoDBConnector settings, dataSource
  # dataSource.connector.connect callback if callback?


###
