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:
parent
6e34087777
commit
a053fe6239
1 changed files with 15 additions and 4 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue