Class: Mongoid::EncryptedHash
- Inherits:
-
Hash
- Object
- Hash
- Mongoid::EncryptedHash
- Includes:
- EncryptedField
- Defined in:
- lib/mongoid-encrypted-fields/fields/encrypted_hash.rb
Class Method Summary collapse
-
.convert(object) ⇒ Object
Takes an object representation (Hash or string) and converts it to an EncryptedHash.
-
.from_hash(h) ⇒ Object
converts from a plain Hash to an EncryptedHash.
Instance Method Summary collapse
-
#raw_value ⇒ Object
Return value to be encrypted.
Methods included from EncryptedField
Class Method Details
.convert(object) ⇒ Object
Takes an object representation (Hash or string) and converts it to an EncryptedHash.
39 40 41 42 43 44 45 46 |
# File 'lib/mongoid-encrypted-fields/fields/encrypted_hash.rb', line 39 def convert(object) case object when Hash from_hash(object) else from_hash(::YAML.load(object)) end end |
.from_hash(h) ⇒ Object
converts from a plain Hash to an EncryptedHash
33 34 35 |
# File 'lib/mongoid-encrypted-fields/fields/encrypted_hash.rb', line 33 def from_hash(h) self[h.to_hash] end |
Instance Method Details
#raw_value ⇒ Object
Return value to be encrypted
26 27 28 |
# File 'lib/mongoid-encrypted-fields/fields/encrypted_hash.rb', line 26 def raw_value stringify_keys.to_yaml end |