metamaps--metamaps/app/serializers/event_serializer.rb

17 lines
402 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-11-06 16:15:18 +00:00
class EventSerializer < ActiveModel::Serializer
attributes :id, :sequence_id, :kind, :map_id, :created_at
has_one :actor, serializer: Api::V2::UserSerializer, root: 'users'
has_one :map, serializer: Api::V2::MapSerializer
def actor
object.user || object.eventable.try(:user)
end
def map
object.eventable.try(:map) || object.eventable.map
end
end