mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 00:43:39 +08:00
23 lines
399 B
Ruby
23 lines
399 B
Ruby
# frozen_string_literal: true
|
|
|
|
class TopListSerializer < ApplicationSerializer
|
|
|
|
attributes :can_create_topic
|
|
|
|
def can_create_topic
|
|
scope.can_create?(Topic)
|
|
end
|
|
|
|
TopTopic.periods.each do |period|
|
|
attribute period
|
|
|
|
define_method(period) do
|
|
if resolved = object.public_send(period)
|
|
TopicListSerializer.new(resolved, scope: scope).as_json
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
end
|