                 when 'string'
                     @readTSV(fx.fixtureDir, fx.data)
                 when 'function'
-                    fx.data(@entityPool)
+                    fx.data.call(new Scope(@, fx), @entityPool)
                 when 'object'
                     fx.data
 


        modelName = modelNames.shift()

        Promise.all(@loadAndSaveModels(modelName)).then =>
            @saveAsync(modelNames)

        .catch (e) =>

            console.error e.message
            return

        ids = Object.keys(data)
        debug('inserting %s models into %s', ids.length, modelName)

        # save models portion by portion, considering parallel connection size
        PORTION_SIZE = 5
        do saveModelsByPortion = =>
            return if ids.length is 0

            idsPortion = ids.slice(0, PORTION_SIZE)
            ids = ids.slice(idsPortion.length)

            results = for id in idsPortion
                obj = data[id]
                obj.id = id
                @saveModel(repo, obj)

            if results[0] instanceof Promise
                Promise.all(results).then => saveModelsByPortion()
            else
                saveModelsByPortion()



    saveModel: (repo, obj) ->

        result = repo.save obj,
            method : 'create'
            force  : true
            include:
                entityPool: @entityPool

        if result instanceof Promise
            result.then (entity) =>
                @entityPool.set entity

        else
            @entityPool.set result



    ###*
