discourse/app/serializers/top_list_serializer.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
399 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2013-12-23 18:50:36 -05:00
class TopListSerializer < ApplicationSerializer
attributes :can_create_topic
def can_create_topic
scope.can_create?(Topic)
end
2013-12-23 18:50:36 -05:00
TopTopic.periods.each do |period|
2014-01-13 19:02:14 -05:00
attribute period
2013-12-23 18:50:36 -05:00
define_method(period) do
if resolved = object.public_send(period)
TopicListSerializer.new(resolved, scope: scope).as_json
2019-05-06 21:27:05 -04:00
end
2013-12-23 18:50:36 -05:00
end
2014-01-13 19:02:14 -05:00
2013-12-23 18:50:36 -05:00
end
end