2018-10-10 23:35:09 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Api
|
|
|
|
module V1
|
|
|
|
class CommentSerializer < ActiveModel::Serializer
|
|
|
|
type :comments
|
|
|
|
attributes :id, :message
|
|
|
|
|
|
|
|
belongs_to :user, serializer: UserSerializer
|
2018-10-11 14:51:14 +08:00
|
|
|
belongs_to :project,
|
|
|
|
serializer: ProjectSerializer,
|
|
|
|
if: -> { object.class == ProjectComment &&
|
|
|
|
!instance_options[:hide_project] }
|
2018-10-10 23:35:09 +08:00
|
|
|
# TODO
|
2018-10-11 14:51:14 +08:00
|
|
|
#belongs_to :my_module,
|
|
|
|
# serializer: TaskSerializer,
|
|
|
|
# key: :task,
|
|
|
|
# class_name: 'MyModule',
|
|
|
|
# if: -> { object.class == TaskComment &&
|
|
|
|
# !instance_options[:hide_task] }
|
|
|
|
#belongs_to :step,
|
|
|
|
# serializer: StepSerializer,
|
|
|
|
# if: -> { object.class == StepComment &&
|
|
|
|
# !instance_options[:hide_step] }
|
|
|
|
belongs_to :result,
|
|
|
|
serializer: ResultSerializer,
|
|
|
|
if: -> { object.class == ResultComment &&
|
|
|
|
!instance_options[:hide_result] }
|
2021-08-18 16:00:01 +08:00
|
|
|
|
|
|
|
include TimestampableModel
|
2018-10-10 23:35:09 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|