Module: Mongoid::Encryptor::ClassMethods
- Defined in:
- lib/mongoid/encryptor.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#encrypts(*attrs) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mongoid/encryptor.rb', line 13 def encrypts(*attrs) = attrs.last.is_a?(Hash) ? attrs.pop : {} attrs.each do |attr_name| = .dup attr_name = attr_name.to_s mode = .delete(:mode) || :sha cipher_class = EncryptedStrings.const_get("#{mode.to_s.classify}Cipher") send(:after_validation) do |doc| doc.send(:write_encrypted_attribute, attr_name, cipher_class, ) true end define_method(attr_name) do read_encrypted_attribute(attr_name, cipher_class, ) end end end |