Permalink
Browse files

Track decrypted columns.

  • Loading branch information...
jmckible committed Jun 17, 2008
1 parent d562f4e commit b8f6a1ec57de6ac2788759b218dd21ab8c027c08
Showing with 8 additions and 2 deletions.
  1. +4 −2 lib/lucifer.rb
  2. +4 −0 test/lucifer_test.rb
View
@@ -5,9 +5,11 @@ def self.included(base)
module ClassMethods
def encrypt_attributes
- cattr_accessor :encrypted_columns
+ cattr_accessor :encrypted_columns, :decrypted_columns
+
self.encrypted_columns = columns.select{|col| col.type == :binary && col.name =~ /_b$/}.collect(&:name)
- encrypted_columns.each { |col| attr_accessor col.chomp('_b') }
+ self.decrypted_columns = encrypted_columns.collect{|col| col.chomp '_b' }
+ decrypted_columns.each { |col| attr_accessor col }
end
end
View
@@ -17,6 +17,10 @@ def test_encrypt_proper_columns
assert_equal ['ssn_b'], Person.encrypted_columns
end
+ def test_track_decrypted_columns
+ assert_equal ['ssn'], Person.decrypted_columns
+ end
+
def test_setup_virtual_attributes
assert Person.new.respond_to?(:ssn)
assert Person.new.respond_to?('ssn=')

0 comments on commit b8f6a1e

Please sign in to comment.