This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/serializers/top_list_serializer.rb
2014-02-06 11:39:43 +01:00

22 lines
419 B
Ruby

class TopListSerializer < ApplicationSerializer
attributes :can_create_topic,
:draft,
:draft_key,
:draft_sequence
def can_create_topic
scope.can_create?(Topic)
end
TopTopic.periods.each do |period|
attribute period
define_method(period) do
TopicListSerializer.new(object.send(period), scope: scope).as_json if object.send(period)
end
end
end