discourse/app/serializers/top_list_serializer.rb

20 lines
380 B
Ruby
Raw Normal View History

2013-12-23 18:50:36 -05:00
class TopListSerializer < ApplicationSerializer
attributes :can_create_topic,
:yearly,
:monthly,
:weekly,
:daily
def can_create_topic
scope.can_create?(Topic)
end
TopTopic.periods.each do |period|
define_method(period) do
TopicListSerializer.new(object[period], scope: scope).as_json
end
end
end