Module: Authenticate::Modules::ClassMethods
- Defined in:
- lib/authenticate/modules.rb
Overview
Module to help Authenticate’s user model load Authenticate modules.
All Authenticate modules implement ActiveSupport::Concern.
Modules can optionally define a class method to define what attributes they require present in the user model. For example, :username declares:
module Username
extend ActiveSupport::Concern
def self.required_fields(klass)
[:username]
end
...
If the model class is missing a required field, Authenticate will fail with a MissingAttribute error. The error will declare what required fields are missing.
Instance Method Summary collapse
-
#load_modules ⇒ Object
Load all modules declared in Authenticate.configuration.modules.
Instance Method Details
#load_modules ⇒ Object
Load all modules declared in Authenticate.configuration.modules. Requires them, then loads as a constant, then checks fields, and finally includes.
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/authenticate/modules.rb', line 26 def load_modules constants = [] Authenticate.configuration.modules.each do |mod| # puts "load_modules about to load #{mod.to_s}" require "authenticate/model/#{mod.to_s}" if mod.is_a?(Symbol) mod = load_constant(mod) if mod.is_a?(Symbol) constants << mod end check_fields constants constants.each { |mod| include mod } end |