2010-10-10 11:51:12 -04:00
|
|
|
require 'orm_adapter/adapters/mongoid'
|
|
|
|
|
2009-11-13 17:54:21 -05:00
|
|
|
module Devise
|
|
|
|
module Orm
|
2010-03-26 15:25:12 -04:00
|
|
|
module Mongoid
|
2010-02-19 03:26:17 -05:00
|
|
|
module Hook
|
|
|
|
def devise_modules_hook!
|
|
|
|
extend Schema
|
|
|
|
yield
|
|
|
|
return unless Devise.apply_schema
|
|
|
|
devise_modules.each { |m| send(m) if respond_to?(m, true) }
|
2009-11-13 19:33:00 -05:00
|
|
|
end
|
2009-11-13 17:54:21 -05:00
|
|
|
end
|
2010-06-13 05:48:35 -04:00
|
|
|
|
2010-02-19 03:26:17 -05:00
|
|
|
module Schema
|
|
|
|
include Devise::Schema
|
|
|
|
|
2010-03-26 15:25:12 -04:00
|
|
|
# Tell how to apply schema methods
|
2010-06-13 05:48:35 -04:00
|
|
|
def apply_devise_schema(name, type, options={})
|
2010-02-19 03:26:17 -05:00
|
|
|
type = Time if type == DateTime
|
2010-09-26 13:08:25 -04:00
|
|
|
field name, { :type => type }.merge!(options)
|
2010-02-03 00:00:03 -05:00
|
|
|
end
|
|
|
|
end
|
2009-11-13 17:54:21 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-03-29 18:29:57 -04:00
|
|
|
Mongoid::Document::ClassMethods.class_eval do
|
|
|
|
include Devise::Models
|
|
|
|
include Devise::Orm::Mongoid::Hook
|
2010-09-26 13:08:25 -04:00
|
|
|
end
|