2014-03-05 18:22:20 +05:30
|
|
|
class UserBadgeSerializer < ApplicationSerializer
|
2014-06-28 00:38:03 +05:30
|
|
|
attributes :id, :granted_at, :count, :post_id
|
2014-03-05 18:22:20 +05:30
|
|
|
|
|
|
|
has_one :badge
|
2014-04-17 21:57:42 +05:30
|
|
|
has_one :user, serializer: BasicUserSerializer, root: :users
|
2014-03-05 18:22:20 +05:30
|
|
|
has_one :granted_by, serializer: BasicUserSerializer, root: :users
|
2014-06-28 00:38:03 +05:30
|
|
|
has_one :topic, serializer: BasicTopicSerializer
|
2014-05-21 12:52:42 +05:30
|
|
|
|
|
|
|
def include_count?
|
|
|
|
object.respond_to? :count
|
|
|
|
end
|
2014-06-28 00:38:03 +05:30
|
|
|
|
|
|
|
def include_post_id?
|
|
|
|
!object.post_id.nil?
|
|
|
|
end
|
|
|
|
alias :include_topic? :include_post_id?
|
|
|
|
|
|
|
|
def topic
|
|
|
|
object.post.topic
|
|
|
|
end
|
2014-03-05 18:22:20 +05:30
|
|
|
end
|