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
|
2022-02-28 17:33:43 +08:00
|
|
|
attributes :name, :archived
|
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',
|
2021-07-23 17:56:28 +08:00
|
|
|
unless: -> { object.repository_cells.blank? }
|
2018-10-07 16:07:37 +08:00
|
|
|
belongs_to :repository, key: :inventory,
|
|
|
|
serializer: InventorySerializer,
|
|
|
|
class_name: 'Repository',
|
|
|
|
if: -> { instance_options[:show_repository] }
|
2021-08-18 16:00:01 +08:00
|
|
|
|
|
|
|
include TimestampableModel
|
2018-08-07 20:19:49 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|