module Devise
def self.add_module(module_name, options = {})
Devise.add_module(:party_module, :model => 'party_module/model')
Devise.add_module(:party_module, :strategy => true, :controller => :sessions)
Devise.add_module(:party_module)
== Examples:
name.
All values, except :model, accept also a boolean and will have the same name as the given module
+strategy+ - Symbol representing if this module got a custom *strategy*.
+route+ - Symbol representing the named *route* helper for this module.
+controller+ - Symbol representing the name of an exisiting or custom *controller* for this module.
+model+ - String representing the load path to a custom *model* for this module (to autoload.)
== Options:
Make Devise aware of an 3rd party Devise-module (like invitable). For convenience.
def self.add_module(module_name, options = {}) ALL << module_name options.assert_valid_keys(:strategy, :model, :controller, :route, :no_input) if strategy = options[:strategy] strategy = (strategy == true ? module_name : strategy) STRATEGIES[module_name] = strategy end if controller = options[:controller] controller = (controller == true ? module_name : controller) CONTROLLERS[module_name] = controller end NO_INPUT << strategy if options[:no_input] if route = options[:route] case route when TrueClass key, value = module_name, [] when Symbol key, value = route, [] when Hash key, value = route.keys.first, route.values.flatten else raise ArgumentError, ":route should be true, a Symbol or a Hash" end URL_HELPERS[key] ||= [] URL_HELPERS[key].concat(value) URL_HELPERS[key].uniq! ROUTES[module_name] = key end if options[:model] path = (options[:model] == true ? "devise/models/#{module_name}" : options[:model]) camelized = ActiveSupport::Inflector.camelize(module_name.to_s) Devise::Models.send(:autoload, camelized.to_sym, path) end Devise::Mapping.add_module module_name end