From 2fb79ffa15fb34620e5b3d6efffe0e3c9b4a42a8 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 11 Feb 2021 16:45:03 -0300 Subject: [PATCH] arreglos menores --- app/models/metadata_template.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/metadata_template.rb b/app/models/metadata_template.rb index 7fa9ba7a..8fa5a971 100644 --- a/app/models/metadata_template.rb +++ b/app/models/metadata_template.rb @@ -23,6 +23,7 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type, cache_key + '-' + cache_version end + # XXX: Deberíamos sanitizar durante la asignación? def value=(new_value) @value_was = value self[:value] = new_value @@ -122,6 +123,8 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type, # En caso de que algún campo necesite realizar acciones antes de ser # guardado def save + return true unless changed? + self[:value] = sanitize value self[:value] = encrypt(value) if private? @@ -138,7 +141,7 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type, # Determina si el campo es privado y debería ser cifrado def private? - !!layout.metadata.dig(name, 'private') + layout.metadata.dig(name, 'private').present? end private