2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-26 01:42:27 -05:00
|
|
|
module SuggestedTopicsMixin
|
|
|
|
def self.included(klass)
|
2018-11-11 20:04:30 -06:00
|
|
|
klass.attributes :related_messages
|
2017-09-26 01:42:27 -05:00
|
|
|
klass.attributes :suggested_topics
|
|
|
|
end
|
|
|
|
|
2018-11-11 20:04:30 -06:00
|
|
|
def include_related_messages?
|
|
|
|
object.next_page.nil? && object.related_messages&.topics.present?
|
|
|
|
end
|
|
|
|
|
2017-09-26 01:42:27 -05:00
|
|
|
def include_suggested_topics?
|
|
|
|
object.next_page.nil? && object.suggested_topics&.topics.present?
|
|
|
|
end
|
|
|
|
|
2018-11-11 20:04:30 -06:00
|
|
|
def related_messages
|
|
|
|
object.related_messages.topics.map do |t|
|
|
|
|
SuggestedTopicSerializer.new(t, scope: scope, root: false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-26 01:42:27 -05:00
|
|
|
def suggested_topics
|
|
|
|
object.suggested_topics.topics.map do |t|
|
|
|
|
SuggestedTopicSerializer.new(t, scope: scope, root: false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|