mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 02:04:33 +08:00
26 lines
988 B
Ruby
26 lines
988 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Api
|
|
module V1
|
|
class ResultSerializer < ActiveModel::Serializer
|
|
type :results
|
|
attributes :name, :archived
|
|
belongs_to :user, serializer: UserSerializer
|
|
has_one :result_text, key: :text,
|
|
serializer: ResultTextSerializer,
|
|
class_name: 'ResultText',
|
|
if: -> { object.is_text }
|
|
has_one :result_table, key: :table,
|
|
serializer: ResultTableSerializer,
|
|
class_name: 'ResultTable',
|
|
if: -> { object.is_table }
|
|
has_one :result_asset, key: :file,
|
|
serializer: ResultAssetSerializer,
|
|
class_name: 'ResultAsset',
|
|
if: -> { object.is_asset }
|
|
has_many :result_comments, key: :comments, serializer: CommentSerializer
|
|
|
|
include TimestampableModel
|
|
end
|
|
end
|
|
end
|