5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-14 18:01:42 +00:00

obtener el valor correo para value_was

This commit is contained in:
f 2021-02-17 18:40:07 -03:00
parent 1a2d7931e9
commit aa66e2cc9b
3 changed files with 15 additions and 3 deletions

View file

@ -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

View file

@ -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

View file

@ -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