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

23 lines
508 B
Ruby
Raw Normal View History

2016-08-20 12:32:18 +08:00
module Api
module V1
class MappingSerializer < ActiveModel::Serializer
attributes :id,
:xloc,
:yloc,
:created_at,
:updated_at,
:mappable_id,
:mappable_type
has_one :user, serializer: UserSerializer
has_one :map, serializer: MapSerializer
def filter(keys)
keys.delete(:xloc) unless object.mappable_type == 'Topic'
keys.delete(:yloc) unless object.mappable_type == 'Topic'
keys
end
end
end
end