How to write a Devise extension (to use a custom datastore)
===

I'd like to write an extension for Devise that allows you to use [parse_resource][1] as the datastore (as opposed to ActiveRecord). parse_resource is a Ruby wrapper for Parse.com's REST api. It's interface is pretty much the same as ActiveRecord's and is ActiveModel complaint. Because of this, it seems possible that an extension for Devise may not require too much non-boilerplate.

However, I can't find any tutorials. All I have to rely on are the sources for other extensions. From the [MongoMapper extension][2], I gather that there are two main parts:

 1. [The generators][3] (not quite required)
    
  Here you overwrite `DeviseGenerator#(generate_model|inject_devise_content|replace_default_devise_orm)` methods.

 2. [The "guts][4]" (very much required)

   I'm not quite as sure what's going on here. It seems that there's a lot of boilerplate, with a little bit of custom type-casting, and at the bottom there's a declaration that we'll be using this extension instead of the default ORM.

Is that all there is to it? What am I missing? Can someone explain what happens in "the guts" in a bit more detail?

Thanks.


  [1]: https://github.com/adelevie/parse_resource
  [2]: https://github.com/kristianmandrup/mm-devise
  [3]: https://github.com/kristianmandrup/mm-devise/blob/master/lib/generators/mongo_mapper/devise_generator.rb
  [4]: https://github.com/kristianmandrup/mm-devise/blob/master/lib/devise/orm/mongo_mapper.rb