discourse/app/serializers/topic_link_serializer.rb

44 lines
610 B
Ruby
Raw Normal View History

2013-02-05 14:16:51 -05:00
class TopicLinkSerializer < ApplicationSerializer
2013-02-19 16:08:23 -05:00
attributes :url,
:title,
:fancy_title,
:internal,
:reflection,
:clicks,
:user_id
2013-02-05 14:16:51 -05:00
def url
object['url']
end
def title
object['title']
end
2013-02-19 16:08:23 -05:00
def fancy_title
object['fancy_title']
end
2013-02-05 14:16:51 -05:00
def internal
object['internal'] == 't'
end
def reflection
object['reflection'] == 't'
end
def clicks
object['clicks'] || 0
end
def user_id
object['user_id'].to_i
end
2013-02-19 16:08:23 -05:00
2013-02-05 14:16:51 -05:00
def include_user_id?
object['user_id'].present?
end
2013-02-07 10:45:24 -05:00
end