5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-14 17:51:41 +00:00

valores de un checkbox y asegurar que los nombres de metadatos sean simbolos

This commit is contained in:
f 2020-07-23 16:06:29 -03:00
parent 1b5541f76c
commit 093845c8e8
2 changed files with 11 additions and 2 deletions

View file

@ -28,6 +28,15 @@ class MetadataBoolean < MetadataTemplate
return document.data.fetch(name.to_s, default_value) if self[:value].nil?
return self[:value] unless self[:value].is_a? String
self[:value] = self[:value] == '1'
self[:value] = true_values.include? self[:value]
end
private
# Los valores que evalúan a verdadero
#
# XXX: memoizamos porque Struct no puede declarar constantes.
def true_values
@true_values ||= %w[1 on true].freeze
end
end

View file

@ -51,7 +51,7 @@ class Post < OpenStruct
MetadataFactory.build(document: document,
post: self,
site: site,
name: name,
name: name.to_sym,
value: args[name.to_sym],
layout: layout,
type: template['type'],