Extract mentionable content using reflection to remove duplicated logic and the need for additional concerns

This commit is contained in:
Jorge Manrubia
2025-04-22 14:19:45 +02:00
parent 9db675e589
commit d5f0359338
3 changed files with 6 additions and 22 deletions
-11
View File
@@ -1,11 +0,0 @@
module Card::Mentions
extend ActiveSupport::Concern
included do
include ::Mentions
end
def mentionable_content
description.to_plain_text
end
end
+6
View File
@@ -12,6 +12,12 @@ module Mentions
end
end
def mentionable_content
self.class.reflect_on_all_associations(:has_one).filter { it.klass == ActionText::Markdown }.collect do |association|
send(association.name).to_plain_text
end.join(" ")
end
private
def collect_mentions_later
Mention::CollectJob.perform_later(self, mentioner: Current.user)
-11
View File
@@ -1,11 +0,0 @@
module Message::Mentions
extend ActiveSupport::Concern
included do
include ::Mentions
end
def mentionable_content
messageable.try(:body_plain_text)
end
end