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