5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 01:06:21 +00:00
panel/app/models/metadata_date.rb

19 lines
413 B
Ruby

# frozen_string_literal: true
class MetadataDate < MetadataTemplate
def default_value
Date.today
end
# Ver MetadataDocumentDate
def value
return self[:value] if self[:value].is_a? Date
return self[:value] if self[:value].is_a? Time
begin
self[:value] = Date.parse(self[:value] || document.data[name.to_s])
rescue ArgumentError, TypeError
default_value
end
end
end