metamaps--metamaps/app/serializers/api/v2/map_serializer.rb
Devin Howard e544d6a6db refactor api and fix bugs (#1088)
* fix weird double-embed issue

* fix users/current api if not logged in

* turbocharge the api

* fix docs
2017-03-09 14:24:52 -05:00

35 lines
775 B
Ruby

# frozen_string_literal: true
module Api
module V2
class MapSerializer < ApplicationSerializer
attributes :id,
:name,
:desc,
:permission,
:screenshot,
:starred,
:created_at,
:updated_at
def starred
object.starred_by_user?(scope[:current_user])
end
def self.embeddable
{
user: {},
source: { serializer: MapSerializer },
topics: {},
synapses: {},
mappings: {},
contributors: { serializer: UserSerializer },
collaborators: { serializer: UserSerializer }
}
end
class_eval do
embed_dat
end
end
end
end