discourse/app/serializers/top_list_serializer.rb

19 lines
332 B
Ruby
Raw Normal View History

2013-12-24 07:50:36 +08:00
class TopListSerializer < ApplicationSerializer
attribute :can_create_topic
def can_create_topic
scope.can_create?(Topic)
end
2013-12-24 07:50:36 +08:00
TopTopic.periods.each do |period|
2014-01-14 08:02:14 +08:00
attribute period
2013-12-24 07:50:36 +08:00
define_method(period) do
2014-01-14 08:02:14 +08:00
TopicListSerializer.new(object[period], scope: scope).as_json if object[period]
2013-12-24 07:50:36 +08:00
end
2014-01-14 08:02:14 +08:00
2013-12-24 07:50:36 +08:00
end
end