1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Merge pull request #3328 from stephenbaldwin/master

Ability to load modules in specific order
This commit is contained in:
José Valim 2014-11-20 22:39:43 +01:00
commit d3d9fba201

View file

@ -348,6 +348,7 @@ module Devise
# +controller+ - Symbol representing the name of an existing or custom *controller* for this module. # +controller+ - Symbol representing the name of an existing or custom *controller* for this module.
# +route+ - Symbol representing the named *route* helper for this module. # +route+ - Symbol representing the named *route* helper for this module.
# +strategy+ - Symbol representing if this module got a custom *strategy*. # +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 # All values, except :model, accept also a boolean and will have the same name as the given module
# name. # name.
@ -357,10 +358,12 @@ module Devise
# Devise.add_module(:party_module) # Devise.add_module(:party_module)
# Devise.add_module(:party_module, strategy: true, controller: :sessions) # Devise.add_module(:party_module, strategy: true, controller: :sessions)
# Devise.add_module(:party_module, model: 'party_module/model') # Devise.add_module(:party_module, model: 'party_module/model')
# Devise.add_module(:party_module, insert_at: 0)
# #
def self.add_module(module_name, options = {}) def self.add_module(module_name, options = {})
ALL << module_name options.assert_valid_keys(:strategy, :model, :controller, :route, :no_input, :insert_at)
options.assert_valid_keys(:strategy, :model, :controller, :route, :no_input)
ALL.insert (options[:insert_at] || -1), module_name
if strategy = options[:strategy] if strategy = options[:strategy]
strategy = (strategy == true ? module_name : strategy) strategy = (strategy == true ? module_name : strategy)