 
   @toArray: (selector = {}, options = {}) ->
     for attributes in @where(selector, options).fetch()
-      # eval is ok, because _type is never entered by user
       new(eval(attributes._type) ? @)(attributes)
 
   @count: (selector = {}, options = {}) ->


  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) ->

class @Minimongoid
  id: undefined
  attributes: {}

