Module: Userify::User

Defined in:
lib/userify/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
24
25
26
27
28
# File 'lib/userify/user.rb', line 6

def self.included(model)
  require 'userify/uid'
  
  model.extend ClassMethods
  model.send(:include, InstanceMethods)
  
  model.class_eval do
    attr_accessible :username, :email, :password, :fullname
    attr_accessor :password
    
    validates_length_of       :username, :maximum => columns_hash['username'].limit
    validates_uniqueness_of   :username, :case_sensitive => false
    validates_length_of       :email, :maximum => columns_hash['email'].limit
    validates_format_of       :email, :with => /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/
    validates_uniqueness_of   :email, :case_sensitive => false
    validates_presence_of     :password, :if => :password_required?
    validates_length_of       :fullname, :maximum => columns_hash['fullname'].limit, :allow_nil => true
    
    before_validation           :userify_before_validation
    before_validation_on_create :userify_before_validation_on_create
    before_save                 :userify_before_save
  end
end