2013-02-06 03:16:51 +08:00
|
|
|
class TopicLinkSerializer < ApplicationSerializer
|
|
|
|
|
2013-02-26 00:42:20 +08:00
|
|
|
attributes :url,
|
|
|
|
:title,
|
2013-02-20 05:08:23 +08:00
|
|
|
:fancy_title,
|
2013-02-26 00:42:20 +08:00
|
|
|
:internal,
|
|
|
|
:reflection,
|
|
|
|
:clicks,
|
2013-02-20 05:08:23 +08:00
|
|
|
:user_id
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
def url
|
|
|
|
object['url']
|
|
|
|
end
|
|
|
|
|
|
|
|
def title
|
|
|
|
object['title']
|
|
|
|
end
|
|
|
|
|
2013-02-20 05:08:23 +08:00
|
|
|
def fancy_title
|
|
|
|
object['fancy_title']
|
|
|
|
end
|
|
|
|
|
2013-02-06 03:16:51 +08: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-20 05:08:23 +08:00
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
def include_user_id?
|
|
|
|
object['user_id'].present?
|
|
|
|
end
|
|
|
|
|
2013-02-07 23:45:24 +08:00
|
|
|
end
|