scinote-web/app/serializers/api/v1/comment_serializer.rb

34 lines
1.1 KiB
Ruby
Raw Normal View History

# 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] }
# 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] }
include TimestampableModel
end
end
end