userify 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/Rakefile +1 -1
  2. data/lib/userify/user.rb +16 -6
  3. metadata +1 -1
data/Rakefile CHANGED
@@ -35,7 +35,7 @@ task :default => ['test:all', 'test:features']
35
35
 
36
36
  gem_spec = Gem::Specification.new do |gem_spec|
37
37
  gem_spec.name = "userify"
38
- gem_spec.version = "0.2.2"
38
+ gem_spec.version = "0.2.3"
39
39
  gem_spec.summary = "Super simple authentication system for Rails, using username, email and password."
40
40
  gem_spec.email = "kenn.ejima <at> gmail.com"
41
41
  gem_spec.homepage = "http://github.com/kenn/userify"
@@ -23,12 +23,9 @@ module Userify
23
23
  validates_presence_of :password, :if => :password_required?
24
24
  validates_length_of :fullname, :maximum => columns_hash['fullname'].limit, :allow_nil => true
25
25
 
26
- before_validation {|record| record.email.downcase! unless self.email.nil? }
27
- before_save {|record| record.encrypted_password = encrypt(password) unless password.blank? }
28
- before_create {|record|
29
- record.salt = UID.new(27).to_s
30
- record.set_token 24.hours.from_now
31
- }
26
+ before_validation :userify_before_validation
27
+ before_save :userify_before_save
28
+ before_create :userify_before_create
32
29
  end
33
30
  end
34
31
 
@@ -91,6 +88,19 @@ module Userify
91
88
  def password_required?
92
89
  encrypted_password.blank? or !password.blank?
93
90
  end
91
+
92
+ def userify_before_validation
93
+ self.email.downcase! unless self.email.nil?
94
+ end
95
+
96
+ def userify_before_save
97
+ self.encrypted_password = encrypt(password) unless self.password.blank?
98
+ end
99
+
100
+ def userify_before_create
101
+ self.salt = UID.new(27).to_s
102
+ set_token 24.hours.from_now
103
+ end
94
104
  end
95
105
 
96
106
  module ClassMethods
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: userify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenn Ejima