Module: Cryptonite::ClassMethods

Includes:
KeyExtractor
Defined in:
lib/cryptonite.rb

Instance Method Summary collapse

Instance Method Details

#attr_encrypted(*attributes) ⇒ Object

Attributes listed as encrypted will be transparently encrypted and decrypted in database operations.



25
26
27
28
29
30
31
32
33
34
# File 'lib/cryptonite.rb', line 25

def attr_encrypted(*attributes)
  options = attributes.extract_options!

  public_key = extract_public_key(options)
  private_key = extract_private_key(options)

  serialize_attributes_with_coder(attributes, private_key || public_key)

  self._attr_encrypted = Set.new(attributes.map(&:to_s)) + (_attr_encrypted || [])
end

#encrypted_attributesObject

Returns an array of all the attributes that have been specified as encrypted.



37
38
39
# File 'lib/cryptonite.rb', line 37

def encrypted_attributes
  _attr_encrypted
end