discourse/app/serializers/topic_list_item_serializer.rb

32 lines
605 B
Ruby
Raw Normal View History

require_dependency 'pinned_check'
class TopicListItemSerializer < ListableTopicSerializer
2013-02-05 14:16:51 -05:00
2013-02-25 11:42:20 -05:00
attributes :views,
:like_count,
:visible,
:pinned,
:closed,
:archived,
:starred,
:has_best_of,
:archetype
2013-02-05 14:16:51 -05:00
has_one :category
has_many :posters, serializer: TopicPosterSerializer, embed: :objects
def starred
object.user_data.starred?
end
alias :include_starred? :seen
def posters
object.posters || []
end
def pinned
PinnedCheck.new(object, object.user_data).pinned?
end
2013-02-05 14:16:51 -05:00
end