metamaps--metamaps/app/serializers/api/v1/synapse_serializer.rb

30 lines
672 B
Ruby
Raw Normal View History

2016-08-20 12:32:18 +08:00
module Api
module V1
2016-08-20 13:44:26 +08:00
class SynapseSerializer < ApplicationSerializer
2016-08-20 12:32:18 +08:00
attributes :id,
:desc,
:category,
:weight,
:permission,
:created_at,
:updated_at
2016-08-20 13:44:26 +08:00
#has_one :topic1, root: :topics, serializer: TopicSerializer
#has_one :topic2, root: :topics, serializer: TopicSerializer
#has_one :user, serializer: UserSerializer
def self.embeddable
{
topic1: { attr: :node1, serializer: TopicSerializer },
topic2: { attr: :node2, serializer: TopicSerializer },
user: {}
}
end
self.class_eval do
embed_dat
end
2016-08-20 12:32:18 +08:00
end
end
end