     ml.done(successCallback) if successCallback? && _.isFunction(successCallback)
     ml.externalObject
 
-  loadCollection: (name, options = {}) =>
+  loadCollection: (name, options = {}) ->
     successCallback = options.success
     options = _.omit(options, 'success')
 


  # Access the cache for a particular collection.
  #    manager.storage("time_entries").get(12).get("title")
  storage: (name) =>
    @getCollectionDetails(name).storage

  dataUsage: =>
    sum = 0
    for dataType in @collectionNames()
      sum += @storage(dataType).length
    sum

  reset: =>
    for name, attributes of @collections
      attributes.storage.reset []
      attributes.cache = {}

  # Access details of a collection.  An error will be thrown if the collection cannot be found.
  getCollectionDetails: (name) =>
    @collections[name] || @collectionError(name)

  collectionNames: =>
    _.keys(@collections)

  collectionExists: (name) =>
    !!@collections[name]

  setErrorInterceptor: (interceptor) =>
    @errorInterceptor = interceptor || (handler, modelOrCollection, options, jqXHR, requestParams) -> handler?(jqXHR)

  loadModel: (name, id, options = {}) =>
    return if not id

    successCallback = options.success

    cl.done(successCallback) if successCallback? && _.isFunction(successCallback)
    cl.externalObject

  collectionError: (name) ->
    Brainstem.Utils.throwError("Unknown collection #{name} in StorageManager.  Known collections: #{_(@collections).keys().join(", ")}")

  createNewCollection: (collectionName, models = [], options = {}) ->
    loaded = options.loaded
    delete options.loaded
    collection = new (@getCollectionDetails(collectionName).klass)(models, options)
    collection.setLoaded(true, trigger: false) if loaded
    collection

  createNewModel: (modelName, options) ->
    new (@getCollectionDetails(modelName.pluralize()).modelKlass)(options || {})

  # Expectations and stubbing

  stub: (collectionName, options) ->
    if @expectations?
      expectation = new Brainstem.Expectation(collectionName, options, @)
      @expectations.push expectation
