2018-08-08 22:55:51 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Api
|
|
|
|
module V1
|
|
|
|
class InventoryColumnSerializer < ActiveModel::Serializer
|
|
|
|
type :inventory_columns
|
|
|
|
attributes :name, :data_type
|
2018-10-07 19:28:29 +08:00
|
|
|
has_many :repository_list_items,
|
|
|
|
key: :inventory_list_items,
|
|
|
|
serializer: InventoryListItemSerializer,
|
|
|
|
class_name: 'RepositoryListItem',
|
2018-10-16 21:35:02 +08:00
|
|
|
if: (lambda do
|
|
|
|
object.data_type == 'RepositoryListValue' &&
|
|
|
|
!instance_options[:hide_list_items]
|
|
|
|
end)
|
|
|
|
|
|
|
|
def data_type
|
|
|
|
Extends::API_REPOSITORY_DATA_TYPE_MAPPINGS[object.data_type]
|
|
|
|
end
|
2018-08-08 22:55:51 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|