mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-18 23:21:30 +08:00
17 lines
563 B
Ruby
17 lines
563 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Api
|
|
module V1
|
|
class ProtocolSerializer < ActiveModel::Serializer
|
|
type :protocols
|
|
attributes :id, :name, :authors, :description, :protocol_type
|
|
has_many :protocol_keywords,
|
|
key: :keywords,
|
|
serializer: ProtocolKeywordSerializer,
|
|
class_name: 'ProtocolKeyword',
|
|
unless: -> { object.protocol_keywords.empty? }
|
|
belongs_to :parent, serializer: ProtocolSerializer,
|
|
if: -> { object.parent.present? }
|
|
end
|
|
end
|
|
end
|