Module: Clearance::User

Defined in:
lib/clearance/user.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.included(model) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/clearance/user.rb', line 6

def self.included(model)
  model.extend ClassMethods
  model.send(:include, InstanceMethods)

  model.class_eval do
    attr_accessible :email, :password, :password_confirmation
    attr_accessor :password, :password_confirmation

    validates_presence_of     :email
    validates_uniqueness_of   :email, :case_sensitive => false
    validates_format_of       :email, :with => %r{.+@.+\..+}

    validates_presence_of     :password, :if => :password_required?
    validates_confirmation_of :password, :if => :password_required?

    before_save :initialize_salt, :encrypt_password, :initialize_token
  end
end