Class: Spree::SecretPreferences::TextHashSerializer
- Inherits:
-
Object
- Object
- Spree::SecretPreferences::TextHashSerializer
- Defined in:
- app/models/concerns/spree/secret_preferences.rb
Overview
The column is text, since ciphertext cannot live in a JSON column. An
empty column stays nil rather than {}: encrypted attributes compare the
stored value with the loaded one, so {} would mark every record without
secrets as changed.
Class Method Summary collapse
Class Method Details
.dump(hash) ⇒ Object
29 30 31 |
# File 'app/models/concerns/spree/secret_preferences.rb', line 29 def self.dump(hash) ActiveSupport::JSON.encode(hash) unless hash.nil? end |
.load(json) ⇒ Object
33 34 35 |
# File 'app/models/concerns/spree/secret_preferences.rb', line 33 def self.load(json) Spree::Metadata::HashSerializer.load(ActiveSupport::JSON.decode(json)) unless json.nil? end |