jmazzi/crypt_keeper — pull request #19 by ghandal (2012-12-09 16:14:43+00:00)
Title: Type casting for encrypted attributes

I need to encrypt non-string attributes so I've added type casting to `crypt_keeper`. You can pass `type_casts` hash to options to enable typecasting.

Type casting is done using `ActiveRecord::ConnectionAdapters::Column` class methods (in similar way `ActiveRecord` does it for regular attributes) when calling attribute reader method (I am overriding readers for all `crypt_keeper_fields`).

I've also improved working with `PostgresPgp` encryptor - you have `decrypted` scope that allow you to retrieve decrypted values from database in one query (in old way, when you had `n` encrypted attributes, you had `n+1` database queries when retrieving one record - one `SELECT` query for record and `n` queries for decrypting encrypted attributes). With `decrypted` scope you would fire only one query.