2013-02-05 14:16:51 -05:00
|
|
|
require_dependency 'excerpt_type'
|
|
|
|
|
|
|
|
class CategoryExcerptSerializer < ActiveModel::Serializer
|
|
|
|
include ExcerptType
|
2013-02-07 10:45:24 -05:00
|
|
|
|
2013-03-14 09:16:57 -04:00
|
|
|
attributes :excerpt, :name, :color, :text_color, :slug, :topic_url, :topics_year,
|
2013-02-05 14:16:51 -05:00
|
|
|
:topics_month, :topics_week, :category_url, :can_edit, :can_delete
|
|
|
|
|
|
|
|
|
|
|
|
def topics_year
|
|
|
|
object.topics_year || 0
|
|
|
|
end
|
|
|
|
|
|
|
|
def topics_month
|
|
|
|
object.topics_month || 0
|
|
|
|
end
|
|
|
|
|
|
|
|
def topics_week
|
|
|
|
object.topics_week || 0
|
2013-02-07 10:45:24 -05:00
|
|
|
end
|
2013-02-05 14:16:51 -05:00
|
|
|
|
|
|
|
def category_url
|
|
|
|
"/category/#{object.slug}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_edit
|
|
|
|
scope.can_edit?(object)
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_delete
|
|
|
|
scope.can_delete?(object)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|