sutty/app/models/metadata_document_date.rb

19 lines
353 B
Ruby
Raw Normal View History

2019-08-08 18:28:23 +00:00
# frozen_string_literal: true
2019-08-07 21:35:37 +00:00
# Maneja la fecha del document
class MetadataDocumentDate < MetadataTemplate
# La fecha por defecto es ahora!
def default_value
Date.today.to_time
end
def value
self[:value] || document.date || default_value
end
2019-08-13 23:33:57 +00:00
def value=(date)
date = date.to_time if date.is_a? String
super(date)
end
2019-08-07 21:35:37 +00:00
end