-class Minimongoid
+class @Minimongoid
   id: undefined
   attributes: {}
 

  @_collection: undefined
  @_type: undefined

  # Rubists will love me, everyone else will burn me!
  #
  # Allows calls like User.new firstname: 'John'
  @new: (attributes) ->
    new @(attributes)



  save: ->
    return false unless @isValid()

    attributes = @mongoize(@attributes)
    attributes['_type'] = @constructor._type if @constructor._type?

    if @isPersisted()
      @constructor._collection.update @id, { $set: attributes }
    else
      @id = @constructor._collection.insert attributes

    this

  update: (@attributes) ->
