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

19 lines
465 B
Ruby
Raw Normal View History

2016-08-20 12:28:28 +08:00
class MappingSerializer < ActiveModel::Serializer
attributes :id,
:xloc,
:yloc,
:created_at,
2016-03-13 02:28:39 +11:00
:updated_at,
:mappable_id,
:mappable_type
2016-08-20 12:28:28 +08:00
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