diff --git a/lib/devise.rb b/lib/devise.rb index 5a6fa9db..3be7f325 100644 --- a/lib/devise.rb +++ b/lib/devise.rb @@ -348,6 +348,7 @@ module Devise # +controller+ - Symbol representing the name of an existing or custom *controller* for this module. # +route+ - Symbol representing the named *route* helper for this module. # +strategy+ - Symbol representing if this module got a custom *strategy*. + # +insert_at+ - Integer representing the order in which this module's model will be included # # All values, except :model, accept also a boolean and will have the same name as the given module # name. @@ -357,10 +358,12 @@ module Devise # Devise.add_module(:party_module) # Devise.add_module(:party_module, strategy: true, controller: :sessions) # Devise.add_module(:party_module, model: 'party_module/model') + # Devise.add_module(:party_module, insert_at: 0) # def self.add_module(module_name, options = {}) - ALL << module_name - options.assert_valid_keys(:strategy, :model, :controller, :route, :no_input) + options.assert_valid_keys(:strategy, :model, :controller, :route, :no_input, :insert_at) + + ALL.insert (options[:insert_at] || -1), module_name if strategy = options[:strategy] strategy = (strategy == true ? module_name : strategy)