Permalink
Browse files

Remove InstanceMethods module. It's deprecated in 3.2 and unnecessary…

… in all versions.
  • Loading branch information...
1 parent 214d1dd commit 6e57d10db5f1a91c5f199d2d1eec8b141077cb71 @gabebw gabebw committed Feb 2, 2012
Showing with 72 additions and 74 deletions.
  1. +72 −74 lib/clearance/user.rb
View
146 lib/clearance/user.rb
@@ -67,94 +67,92 @@ module Callbacks
end
end
- module InstanceMethods
- # Set the remember token.
- #
- # @deprecated Use {#reset_remember_token!} instead
- def remember_me!
- warn "[DEPRECATION] remember_me!: use reset_remember_token! instead"
- reset_remember_token!
- end
+ # Set the remember token.
+ #
+ # @deprecated Use {#reset_remember_token!} instead
+ def remember_me!
+ warn "[DEPRECATION] remember_me!: use reset_remember_token! instead"
+ reset_remember_token!
+ end
- # Reset the remember token.
- #
- # @example
- # user.reset_remember_token!
- def reset_remember_token!
- generate_remember_token
- save(:validate => false)
- end
+ # Reset the remember token.
+ #
+ # @example
+ # user.reset_remember_token!
+ def reset_remember_token!
+ generate_remember_token
+ save(:validate => false)
+ end
- # Mark my account as forgotten password.
- #
- # @example
- # user.forgot_password!
- def forgot_password!
- generate_confirmation_token
- save(:validate => false)
- end
+ # Mark my account as forgotten password.
+ #
+ # @example
+ # user.forgot_password!
+ def forgot_password!
+ generate_confirmation_token
+ save(:validate => false)
+ end
- # Update my password.
- #
- # @return [true, false] password was updated or not
- # @example
- # user.update_password('new-password')
- def update_password(new_password)
- self.password_changing = true
- self.password = new_password
- if valid?
- self.confirmation_token = nil
- generate_remember_token
- end
- save
+ # Update my password.
+ #
+ # @return [true, false] password was updated or not
+ # @example
+ # user.update_password('new-password')
+ def update_password(new_password)
+ self.password_changing = true
+ self.password = new_password
+ if valid?
+ self.confirmation_token = nil
+ generate_remember_token
end
+ save
+ end
- def password=(unencrypted_password)
- @password = unencrypted_password
- encrypt_password
- end
+ def password=(unencrypted_password)
+ @password = unencrypted_password
+ encrypt_password
+ end
- protected
+ protected
- def generate_random_code(length = 20)
- if RUBY_VERSION >= '1.9'
- SecureRandom.hex(length).encode('UTF-8')
- else
- SecureRandom.hex(length)
- end
+ def generate_random_code(length = 20)
+ if RUBY_VERSION >= '1.9'
+ SecureRandom.hex(length).encode('UTF-8')
+ else
+ SecureRandom.hex(length)
end
+ end
- def generate_remember_token
- self.remember_token = generate_random_code
- end
+ def generate_remember_token
+ self.remember_token = generate_random_code
+ end
- def generate_confirmation_token
- self.confirmation_token = generate_random_code
- end
+ def generate_confirmation_token
+ self.confirmation_token = generate_random_code
+ end
- # Always false. Override to allow other forms of authentication
- # (username, facebook, etc).
- # @return [Boolean] true if the email field be left blank for this user
- def email_optional?
- false
- end
+ # Always false. Override to allow other forms of authentication
+ # (username, facebook, etc).
+ # @return [Boolean] true if the email field be left blank for this user
+ def email_optional?
+ false
+ end
- # True if the password has been set and the password is not being
- # updated and we are not updating the password. Override to allow
- # other forms of authentication (username, facebook, etc).
- # @return [Boolean] true if the password field can be left blank for this user
- def password_optional?
- encrypted_password.present? && password.blank? && password_changing.blank?
- end
+ # True if the password has been set and the password is not being
+ # updated and we are not updating the password. Override to allow
+ # other forms of authentication (username, facebook, etc).
+ # @return [Boolean] true if the password field can be left blank for this user
+ def password_optional?
+ encrypted_password.present? && password.blank? && password_changing.blank?
+ end
- def password_required?
- # warn "[DEPRECATION] password_required?: use !password_optional? instead"
- !password_optional?
- end
+ def password_required?
+ # warn "[DEPRECATION] password_required?: use !password_optional? instead"
+ !password_optional?
+ end
- def downcase_email
- self.email = email.to_s.downcase
- end
+ def downcase_email
+ self.email = email.to_s.downcase
end
end
end

0 comments on commit 6e57d10

Please sign in to comment.