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

49 lines
1.2 KiB
Ruby

module Devise
ALL = [:authenticable, :confirmable, :recoverable, :rememberable, :validatable].freeze
# Maps controller names to devise modules
CONTROLLERS = {
:sessions => :authenticable,
:passwords => :recoverable,
:confirmations => :confirmable
}.freeze
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'].freeze
MODEL_CONFIG = []
def self.model_config(klass, accessor, default=nil)
# Create Devise accessor
mattr_accessor accessor
# Set default value
send(:"#{accessor}=", default)
# Store configuration method
MODEL_CONFIG << accessor
# Set default value
klass.class_eval <<-METHOD
def #{accessor}
Devise.#{accessor}
end
METHOD
end
end
# Devise initialization process goes like this:
#
# 1) Include Devise::ActiveRecord and Devise::Migrations
# 2) Load and config warden
# 3) Add routes extensions
# 4) Load routes definitions
# 5) Include filters and helpers in controllers and views
#
Rails.configuration.after_initialize do
ActiveRecord::Base.extend Devise::ActiveRecord
ActiveRecord::ConnectionAdapters::TableDefinition.send :include, Devise::Migrations
end
require 'devise/warden'
require 'devise/mapping'
require 'devise/routes'