discourse/app/serializers/detailed_user_badge_serializer.rb
Sam Saffron 30990006a9 DEV: enable frozen string literal on all files
This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
2019-05-13 09:31:32 +08:00

28 lines
591 B
Ruby

# frozen_string_literal: true
class DetailedUserBadgeSerializer < BasicUserBadgeSerializer
has_one :granted_by, serializer: UserBadgeSerializer::UserSerializer
attributes :post_number, :topic_id, :topic_title
def include_post_number?
object.post
end
alias :include_topic_id? :include_post_number?
alias :include_topic_title? :include_post_number?
def post_number
object.post.post_number if object.post
end
def topic_id
object.post.topic_id if object.post
end
def topic_title
object.post.topic.title if object.post && object.post.topic
end
end