Module: SimplestAuth::Model

Defined in:
lib/simplest_auth/model.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/simplest_auth/model.rb', line 3

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

  base.class_eval do
    attr_accessor :password, :password_confirmation
  end

  if base.data_mapper?
    base.class_eval do
      before(:save) {hash_password if password_required?}
    end
  elsif base.active_record? || base.mongo_mapper?
    base.class_eval do
      before_save :hash_password, :if => :password_required?
    end
  end
end