lib/crypt_keeper/model.rb
# Public: Setup fields for encryption
#
#   args - An array of fields to encrypt. The last argument should be
#   a hash of options. Note, an :encryptor is required. This should be
#   a class that takes a hash for initialize and provides an encrypt
#   and decrypt method.
#
# Example
#
#   class MyModel < ActiveRecord::Base
#     crypt_keeper :field, :other_field, :encryptor => :aes, :key => 'super_good_password'
#   end
#
Setup fields for encryption
args - An array of fields to encrypt. The last argument should be
a hash of options. Note, an :encryptor is required. This should be
a class that takes a hash for initialize and provides an encrypt
and decrypt method.

Example


Setup fields for encryption args - An array of fields to encrypt . The last argument should be a hash of options . Note an : encryptor is required . This should be a class that takes a hash for initialize and provides an encrypt and decrypt method . Example
def crypt_keeper(*args)
        class_attribute :crypt_keeper_fields
        class_attribute :crypt_keeper_encryptor
        class_attribute :crypt_keeper_options
        class_attribute :crypt_keeper_encoding
        self.crypt_keeper_options   = args.extract_options!
        self.crypt_keeper_encryptor = crypt_keeper_options.delete(:encryptor)
        self.crypt_keeper_encoding  = crypt_keeper_options.delete(:encoding)
        self.crypt_keeper_fields    = args
        ensure_valid_encryptor!
        before_save :enforce_column_types_callback
        if self.crypt_keeper_encoding
          after_find :force_encodings_on_fields
          before_save :force_encodings_on_fields
        end
        crypt_keeper_fields.each do |field|
          serialize field, encryptor_klass.new(crypt_keeper_options).
            extend(::CryptKeeper::Helper::Serializer)
        end
      end
def crypt_keeper ( * args ) class_attribute :crypt_keeper_fields class_attribute :crypt_keeper_encryptor class_attribute :crypt_keeper_options class_attribute :crypt_keeper_encoding self . crypt_keeper_options = args . extract_options! self . crypt_keeper_encryptor = crypt_keeper_options . delete ( :encryptor ) self . crypt_keeper_encoding = crypt_keeper_options . delete ( :encoding ) self . crypt_keeper_fields = args ensure_valid_encryptor! before_save :enforce_column_types_callback if self . crypt_keeper_encoding after_find :force_encodings_on_fields before_save :force_encodings_on_fields end crypt_keeper_fields . each do | field | serialize field , encryptor_klass . new ( crypt_keeper_options ) . extend ( :: CryptKeeper :: Helper :: Serializer ) end end
Public: Setup fields for encryption
args - An array of fields to encrypt.
Public : Setup fields for encryption args - An array of fields to encrypt .
args
<not_specific>