class Devise::Mapping

:nodoc:
# is the modules included in the class
mapping.for #=> [:authenticable]
# is the class to be loaded from routes, given in the route as :class_name.
mapping.to #=> User
# how the mapping should be search in the path, given in the route as :as.
mapping.as #=> “users”
# is the scope used in controllers and warden, given in the route as :singular.
mapping.name #=> :user
mapping = Devise.mappings[:user]
map.devise_for :users
inflected to find all other values.
The required value in devise_for is actually not used internally, but it’s
object. You can refer to devise_for in routes for usage options.
resource configured by devise_for in routes is actually creating a mapping
Responsible for handling devise mappings and routes configuration. Each

def allows?(controller)

Check if the respective controller has a module in the mapping class.
def allows?(controller)
  self.for.include?(CONTROLLERS[controller.to_sym])
end

def for

Return modules for the mapping.
def for
  @for ||= to.devise_modules
end

def initialize(name, options)

def initialize(name, options)
  @as    = (options[:as] || name).to_sym
  @klass = (options[:class_name] || name.to_s.classify).to_s
  @name  = (options[:singular] || name.to_s.singularize).to_sym
  @path_names = options[:path_names] || {}
  setup_path_names
end

def setup_path_names

passing a hash in :path_names.
Configure default path names, allowing the user overwrite defaults by
def setup_path_names
  [:sign_in, :sign_out, :password, :confirmation].each do |path_name|
    @path_names[path_name] ||= path_name.to_s
  end
end

def to

Reload mapped class each time when cache_classes is false.
def to
  return @to if @to
  klass = @klass.constantize
  @to = klass if Rails.configuration.cache_classes
  klass
end