Module: Authenticate::Modules::ClassMethods

Defined in:
lib/authenticate/modules.rb

Overview

Class methods injected into User model.

Instance Method Summary collapse

Instance Method Details

#load_modulesObject

Load all modules declared in Authenticate.configuration.modules. Requires them, then loads as a constant, then checks fields, and finally includes.

Raises:

  • MissingAttribute if attributes required by Authenticate are missing.


35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/authenticate/modules.rb', line 35

def load_modules
  modules_to_include = []
  Authenticate.configuration.modules.each do |mod|
    # The built-in modules are referred to by symbol. Additional module classes (constants) can be added
    # via Authenticate.configuration.modules.
    require "authenticate/model/#{mod}" if mod.is_a?(Symbol)
    mod = load_constant(mod) if mod.is_a?(Symbol)
    modules_to_include << mod
  end
  check_fields modules_to_include
  modules_to_include.each { |mod| include mod }
end