mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 08:46:21 +00:00
fix: reusar belongs to
This commit is contained in:
parent
b09d051de1
commit
ce7c7ffd96
1 changed files with 2 additions and 18 deletions
|
@ -1,20 +1,8 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class MetadataHasOne < MetadataBelongsTo
|
class MetadataHasOne < MetadataBelongsTo
|
||||||
def had_one
|
alias has_one belongs_to
|
||||||
return default_value if value_was.blank?
|
alias had_one belonged_to
|
||||||
|
|
||||||
posts.find(value, uuid: true)
|
|
||||||
end
|
|
||||||
|
|
||||||
def has_one
|
|
||||||
return default_value if value.blank?
|
|
||||||
|
|
||||||
posts.find(value, uuid: true)
|
|
||||||
end
|
|
||||||
|
|
||||||
def belonged_to; end
|
|
||||||
def belongs_to; end
|
|
||||||
|
|
||||||
def save
|
def save
|
||||||
# XXX: DRY
|
# XXX: DRY
|
||||||
|
@ -38,8 +26,4 @@ class MetadataHasOne < MetadataBelongsTo
|
||||||
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