From aa66e2cc9b71e6fa5adbdc23d6147ef78481cc3b Mon Sep 17 00:00:00 2001 From: f Date: Wed, 17 Feb 2021 18:40:07 -0300 Subject: [PATCH] obtener el valor correo para value_was --- app/models/metadata_document_date.rb | 6 +++++- app/models/metadata_lang.rb | 6 +++++- app/models/metadata_path.rb | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/models/metadata_document_date.rb b/app/models/metadata_document_date.rb index 036877ae..39e68735 100644 --- a/app/models/metadata_document_date.rb +++ b/app/models/metadata_document_date.rb @@ -7,10 +7,14 @@ class MetadataDocumentDate < MetadataTemplate Date.today.to_time end + def value_from_document + document.date + end + # El valor puede ser un Date, Time o una String en el formato # "yyyy-mm-dd" def value - return (self[:value] = document.date || default_value) if self[:value].nil? + return (self[:value] = value_from_document || default_value) if self[:value].nil? self[:value] = Date.iso8601(self[:value]).to_time if self[:value].is_a? String diff --git a/app/models/metadata_lang.rb b/app/models/metadata_lang.rb index da13d902..93ef87cc 100644 --- a/app/models/metadata_lang.rb +++ b/app/models/metadata_lang.rb @@ -6,8 +6,12 @@ class MetadataLang < MetadataTemplate super || I18n.locale end + def value_from_document + document.collection.label + end + def value - self[:value] ||= document.collection.label || default_value + self[:value] ||= value_from_document || default_value end def values diff --git a/app/models/metadata_path.rb b/app/models/metadata_path.rb index 6dede4b5..3c93cca6 100644 --- a/app/models/metadata_path.rb +++ b/app/models/metadata_path.rb @@ -7,8 +7,12 @@ class MetadataPath < MetadataTemplate File.join(site.path, "_#{lang}", "#{date}-#{slug}#{ext}") end + # El valor no vuelve desde el documento + def value_from_document + document.path + end + def value - @value_was ||= default_value self[:value] = default_value end alias absolute value