2013-12-23 18:50:36 -05:00
|
|
|
class TopListSerializer < ApplicationSerializer
|
|
|
|
|
2014-02-06 05:39:43 -05:00
|
|
|
attributes :can_create_topic,
|
|
|
|
:draft,
|
|
|
|
:draft_key,
|
|
|
|
:draft_sequence
|
2014-01-16 22:38:08 -05:00
|
|
|
|
|
|
|
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
|
2014-02-06 05:39:43 -05:00
|
|
|
TopicListSerializer.new(object.send(period), scope: scope).as_json if object.send(period)
|
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
|