scinote-web/app/serializers/api/v1/protocol_serializer.rb
2018-10-07 13:28:29 +02:00

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