2018-08-07 20:19:49 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Api
|
|
|
|
module V1
|
|
|
|
class InventoryItemSerializer < ActiveModel::Serializer
|
2018-08-08 23:15:08 +08:00
|
|
|
type :inventory_items
|
2018-08-23 20:52:00 +08:00
|
|
|
attributes :name
|
2018-08-07 20:19:49 +08:00
|
|
|
has_many :repository_cells, key: :inventory_cells,
|
|
|
|
serializer: InventoryCellSerializer,
|
2018-10-07 00:37:40 +08:00
|
|
|
class_name: 'RepositoryCell',
|
|
|
|
unless: -> { object.repository_cells.empty? }
|
2018-10-07 16:07:37 +08:00
|
|
|
belongs_to :repository, key: :inventory,
|
|
|
|
serializer: InventorySerializer,
|
|
|
|
class_name: 'Repository',
|
|
|
|
if: -> { instance_options[:show_repository] }
|
2018-08-07 20:19:49 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|