Skip to content

Instantly share code, notes, and snippets.

@rubysolo
Created April 15, 2009 16:01
Show Gist options
  • Save rubysolo/95866 to your computer and use it in GitHub Desktop.
Save rubysolo/95866 to your computer and use it in GitHub Desktop.
# Schema:
#
# id int
# crypted_number string(255)
# ... anything else ...
class Foo < ActiveRecord::Base
attr_writer :number
before_save :encrypt_number
def number
@number ||= decrypt(crypted_number)
end
private
def encrypt_number
crypted_number = encrypt(@number)
end
def encrypt(string)
# super secret crypto algorithm
end
def decrypt(string)
# super secret crypto algorithm
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment