= PasswordAttribute module Author:: Joel Parker Henderson, joelparkerhenderson@gmail.com Copyright:: Copyright (c) 2006-2008 Joel Parker Henderson License:: CreativeCommons License, Non-commercial Share Alike License:: LGPL, GNU Lesser General Public License Easy way to add BCrypt strong password capability to an ActiveRecord model. Example: class User include PasswordAttribute end Example: create new user u=User.new u.password='secret' # automatically converts plain text to bcrypt u.save Example: is a user's password valid? u = User.find(id) or raise 'user not found' u.password=='secret' # automatically converts plain text to bcrypt ... password is valid ... else ... password doesn't match ... end Example: mock testing in irb require 'rubygems' => true require 'active_record_mock' => true require 'bcrypt' => true require 'password_attribute' => true class UserMock < ActiveRecordMock include PasswordAttribute end => UserMock u = UserMock.new => # u.password='secret' => "secret" u.password=='secret' => true u.password == 'wrong' => false