     storage: ( ) ->
         return localStorage
 
+    toJSON: ( obj ) ->
+      if obj.has?("$el")
+        obj.get("$el").toJSON = () ->
+          @clone().wrap('<div/>').parent().html()
+
+      JSON.stringify obj
+
     indexRoot: ( ) ->
       return inflection.transform(@name, ['underscore', 'pluralize'])
 

      indexRoot = @indexRoot?() ? @indexRoot
      key = "#{indexRoot}/#{instance.id}"
      if data?
        key += "/"+Tails.Utils.Hash JSON.stringify data
        json = JSON.stringify
          "instance" : instance
          "data" : data
      else
        json = JSON.stringify instance
      @storage().setItem key, json
      return key


    InstanceMethods: @with Tails.Mixins.Debug,
      included : () =>
        @after initialize: () ->
          console.log @toJSON @name
          @after store: () ->
            @log "Stored instances", @constructor.pluck("id")

