Sha256: 26efd0acf4fa4230e9bb48d250a2e9f8ce58b949c5a44e00d75e985ad75a9ab8
Contents?: true
Size: 1016 Bytes
Versions: 22
Compression:
Stored size: 1016 Bytes
Contents
# frozen_string_literal: true module Praxis class Collection < Attributor::Collection include Types::MediaTypeCommon def self.of(type) return type::Collection if defined?(type::Collection) klass = super klass.anonymous_type raise 'Praxis::Collection.of() for non-MediaTypes is unsupported. Use Attributor::Collection.of() instead.' unless type < Praxis::Types::MediaTypeCommon klass.member_type type type.const_set :Collection, klass end def self.member_type(type = nil) unless type.nil? @member_type = type identifier("#{type.identifier};type=collection") unless type.identifier.nil? end @member_type end def self.domain_model @member_type.domain_model end def self.json_schema_type :array end def self.as_json_schema(**_args) the_type = @attribute&.type || member_type { type: json_schema_type, items: the_type.as_json_schema } end end end
Version data entries
22 entries across 22 versions & 1 rubygems