2015-07-15 08:54:28 -04:00
|
|
|
class PermalinkSerializer < ApplicationSerializer
|
2015-07-20 08:10:22 -04:00
|
|
|
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
|
2015-07-17 06:23:48 -04:00
|
|
|
|
|
|
|
def topic_title
|
|
|
|
object.try(:topic).try(:title)
|
|
|
|
end
|
|
|
|
|
|
|
|
def topic_url
|
|
|
|
object.try(:topic).try(:url)
|
|
|
|
end
|
|
|
|
|
|
|
|
def post_url
|
|
|
|
object.try(:post).try(:url)
|
|
|
|
end
|
|
|
|
|
2015-07-20 08:10:22 -04:00
|
|
|
def post_number
|
|
|
|
object.try(:post).try(:post_number)
|
|
|
|
end
|
|
|
|
|
|
|
|
def post_topic_title
|
|
|
|
object.try(:post).try(:topic).try(:title)
|
|
|
|
end
|
|
|
|
|
2015-07-17 06:23:48 -04:00
|
|
|
def category_name
|
|
|
|
object.try(:category).try(:name)
|
|
|
|
end
|
|
|
|
|
|
|
|
def category_url
|
|
|
|
object.try(:category).try(:url)
|
|
|
|
end
|
2015-07-15 08:54:28 -04:00
|
|
|
end
|