Extract mentionable content using reflection to remove duplicated logic and the need for additional concerns
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
module Card::Mentions
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
include ::Mentions
|
||||
end
|
||||
|
||||
def mentionable_content
|
||||
description.to_plain_text
|
||||
end
|
||||
end
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user