discourse/app/serializers/permalink_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

37 lines
701 B
Ruby

# frozen_string_literal: true
class PermalinkSerializer < ApplicationSerializer
attributes :id, :url, :topic_id, :topic_title, :topic_url,
:post_id, :post_url, :post_number, :post_topic_title,
:category_id, :category_name, :category_url, :external_url
def topic_title
object&.topic&.title
end
def topic_url
object&.topic&.url
end
def post_url
# use `full_url` to support subfolder setups
object&.post&.full_url
end
def post_number
object&.post&.post_number
end
def post_topic_title
object&.post&.topic&.title
end
def category_name
object&.category&.name
end
def category_url
object&.category&.url
end
end