2019-09-17 21:27:51 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Un campo de idioma
|
|
|
|
class MetadataLang < MetadataTemplate
|
2023-10-06 13:53:19 +00:00
|
|
|
include Metadata::NonIndexableConcern
|
|
|
|
include Metadata::AlwaysPublicConcern
|
|
|
|
|
2019-09-17 21:27:51 +00:00
|
|
|
def default_value
|
2020-11-11 18:29:12 +00:00
|
|
|
super || I18n.locale
|
2019-09-17 21:27:51 +00:00
|
|
|
end
|
|
|
|
|
2021-06-16 14:35:37 +00:00
|
|
|
# @return [Symbol]
|
|
|
|
def document_value
|
2021-03-03 12:43:15 +00:00
|
|
|
document.collection.label.to_sym
|
2021-02-17 21:40:07 +00:00
|
|
|
end
|
|
|
|
|
2023-10-06 13:53:19 +00:00
|
|
|
# @return [Symbol]
|
2019-09-17 21:27:51 +00:00
|
|
|
def value
|
2021-06-16 14:35:37 +00:00
|
|
|
self[:value] ||= document_value || default_value
|
2019-09-17 21:27:51 +00:00
|
|
|
end
|
|
|
|
|
2023-10-06 13:53:19 +00:00
|
|
|
# Todos los locales
|
|
|
|
#
|
|
|
|
# @return [Array<Symbol>]
|
2019-09-17 21:27:51 +00:00
|
|
|
def values
|
2020-05-23 15:38:03 +00:00
|
|
|
site.locales
|
2019-09-17 21:27:51 +00:00
|
|
|
end
|
|
|
|
end
|