2021-11-17 23:28:02 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Api
|
|
|
|
module V1
|
|
|
|
class UserAssignmentSerializer < ActiveModel::Serializer
|
|
|
|
type :user_assignments
|
|
|
|
attributes :id
|
2022-03-09 21:12:16 +08:00
|
|
|
belongs_to :user_role, serializer: UserRoleSerializer
|
|
|
|
belongs_to :user, serializer: UserSerializer
|
2021-11-17 23:28:02 +08:00
|
|
|
belongs_to :assignable
|
|
|
|
|
2022-03-09 21:12:16 +08:00
|
|
|
class << self
|
|
|
|
def serializer_for(model, options)
|
|
|
|
return TaskSerializer if model.instance_of? MyModule
|
|
|
|
return ExperimentSerializer if model.instance_of? Experiment
|
|
|
|
return ProjectSerializer if model.instance_of? Project
|
|
|
|
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-11-17 23:28:02 +08:00
|
|
|
include TimestampableModel
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|