Module: Cryptonite::ClassMethods
- Defined in:
- lib/cryptonite.rb
Instance Method Summary collapse
-
#attr_encrypted(*attributes) ⇒ Object
Attributes listed as encrypted will be transparently encrypted and decrypted in database operations.
-
#encrypted_attributes ⇒ Object
Returns an array of all the attributes that have been specified as encrypted.
Instance Method Details
#attr_encrypted(*attributes) ⇒ Object
Attributes listed as encrypted will be transparently encrypted and decrypted in database operations.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cryptonite.rb', line 23 def attr_encrypted(*attributes) = attributes. @public_key = get_rsa_key([:public_key] || [:key_pair] || ENV['PUBLIC_KEY']) @private_key = get_rsa_key([:private_key] || [:key_pair] || ENV['PRIVATE_KEY'], [:private_key_password] || ENV['PRIVATE_KEY_PASSWORD']) for attribute in attributes do serialize attribute, Coder.new(@private_key || @public_key) end self._attr_encrypted = Set.new(attributes.map { |a| a.to_s }) + (self._attr_encrypted || []) end |
#encrypted_attributes ⇒ Object
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 self._attr_encrypted end |