Class: Voynich::Storage
- Inherits:
-
Object
- Object
- Voynich::Storage
- Defined in:
- lib/voynich/storage.rb
Instance Method Summary collapse
- #create(plain_value, key_name: nil, context: {}) ⇒ Object
- #decrypt(uuid, context: {}) ⇒ Object
-
#initialize ⇒ Storage
constructor
A new instance of Storage.
- #update(uuid, plain_value, context: {}) ⇒ Object
Constructor Details
#initialize ⇒ Storage
Returns a new instance of Storage.
5 6 |
# File 'lib/voynich/storage.rb', line 5 def initialize end |
Instance Method Details
#create(plain_value, key_name: nil, context: {}) ⇒ Object
8 9 10 11 12 |
# File 'lib/voynich/storage.rb', line 8 def create(plain_value, key_name: nil, context: {}) data_key = fetch_data_key(key_name) unless key_name.nil? value = ActiveRecord::Value.create!(plain_value: plain_value, data_key: data_key, context: context) value.uuid end |
#decrypt(uuid, context: {}) ⇒ Object
22 23 24 25 26 |
# File 'lib/voynich/storage.rb', line 22 def decrypt(uuid, context: {}) value = ActiveRecord::Value.find_by!(uuid: uuid) value.context = context value.decrypt end |
#update(uuid, plain_value, context: {}) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/voynich/storage.rb', line 14 def update(uuid, plain_value, context: {}) value = ActiveRecord::Value.find_by!(uuid: uuid) value.plain_value = plain_value value.context = context value.save! uuid end |