I\'d like to write an extension for Devise that allows you to use parse_resource as the datastore (as opposed to ActiveRecord). parse_resource is a Ruby wrapper for Parse.com\'s
I think the best approach would be to write an orm_adapter adapter for parse resource. It is the real "guts" of devise's integration with various orms.
It is actually very straightforward and includes a test suite you can use. Considering parse_resource is activemodel compliant, the adapter should be as easy as cloning an existing adapter.
Next you will need to hook in the orm_adapter to devise, which is just a clone of one of these files.
For a good start you can check out the couchDB extension and the Riak extension as well. You can see that in the Hook module you override anything you want/must for making the Devise to work.
Can you see the class_eval declaration at the bottom? There you extend the class (in your case the ParseResource::Base
) with the Devise::Models
module, which holds all the necessary methods (including the famous devise
method as you can see), and next with the Hooks
module if you want to override anything (the MongoMapper extension doen't need to override anything, that's why is not using this method). Thus you must write:
module Devise
module Orm
module ParseResource
module Hooks
# here you define any overrides
end
end
end
end
ParseResource::Base.class_eval do
extend Devise::Models
extend Devise::Orm::ParseResource::Hooks
end
After that you must require 'devise/orm/parse_resource'
(assuming you have named the file parse_resource.rb
) in your #{Rails.root}/config/initializers/devise.rb
initializer. Hope I helped a bit :)