16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/models/adapter/datamapper.rb', line 16
def self.included(base)
base.class_eval do
include ::DataMapper::Resource
include AuthSlice::BaseModel
extend ClassMethods
storage_names[:default] = 'users'
property :id, Integer, :serial => true
property :name, String, :length => 3..40, :nullable => false
property :username, String, :length => 3..40, :nullable => false
property :email, String, :format => :email_address, :nullable => false
property :crypted_password, String, :length => 40
property :salt, String, :length => 40
property :remember_token_expires_at, Date
property :remember_token, String
property :created_at, DateTime
property :updated_at, DateTime
validates_is_unique :username, :email
validates_length :password, :in => 4..40, :if => :password_required?
validates_is_confirmed :password, :groups => :create
before :save, :encrypt_password
def username=(value)
attribute_set(:username, value.downcase) if value
end
end
end
|