5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-27 01:06:23 +00:00

fix: no comportarse como un array

This commit is contained in:
f 2023-04-08 17:36:13 -03:00
parent 6e34087777
commit a053fe6239

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
class MetadataHasOne < MetadataHasMany class MetadataHasOne < MetadataBelongsTo
def had_one def had_one
return default_value if value_was.blank? return default_value if value_was.blank?
@ -13,11 +13,18 @@ class MetadataHasOne < MetadataHasMany
posts.find(uuid: value) posts.find(uuid: value)
end end
def had_many; end def belonged_to; end
def has_many; end def belongs_to; end
def save def save
super # XXX: DRY
if !changed?
self[:value] = document_value
return true
end
self[:value] = sanitize value
return true unless changed? return true unless changed?
return true unless inverse? return true unless inverse?
@ -31,4 +38,8 @@ class MetadataHasOne < MetadataHasMany
def related_methods def related_methods
@related_methods ||= %i[has_one had_one].freeze @related_methods ||= %i[has_one had_one].freeze
end end
def indexable_values
has_one&.title&.value
end
end end