Method: Devise.add_module
- Defined in:
- lib/devise.rb
.add_module(module_name, options = {}) ⇒ Object
Make Devise aware of an 3rd party Devise-module. For convenience.
Options:
+model+ - String representing the load path to a custom *model* for this module (to autoload.)
+controller+ - Symbol representing the name of an exisiting or custom *controller* for this module.
+route+ - Symbol representing the named *route* helper for this module.
+flash+ - Symbol representing the *flash * used by this helper.
+strategy+ - Symbol representing if this module got a custom *strategy*.
All values, except :model, accept also a boolean and will have the same name as the given module name.
Examples:
Devise.add_module(:party_module)
Devise.add_module(:party_module, :strategy => true, :controller => :sessions)
Devise.add_module(:party_module, :model => 'party_module/model')
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/devise.rb', line 224 def self.add_module(module_name, = {}) ALL << module_name .assert_valid_keys(:strategy, :model, :controller, :route) config = { :strategy => STRATEGIES, :route => ROUTES, :controller => CONTROLLERS } config.each do |key, value| next unless [key] name = ([key] == true ? module_name : [key]) if value.is_a?(Hash) value[module_name] = name else value << name unless value.include?(name) end end if [:model] model_path = ([:model] == true ? "devise/models/#{module_name}" : [:model]) Devise::Models.send(:autoload, module_name.to_s.camelize.to_sym, model_path) end Devise::Mapping.add_module module_name end |