mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-22 13:36:21 +00:00
valores de un checkbox y asegurar que los nombres de metadatos sean simbolos
This commit is contained in:
parent
1b5541f76c
commit
093845c8e8
2 changed files with 11 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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'],
|
||||
|
|
Loading…
Reference in a new issue