class Praxis::Collection

Public Class Methods

as_json_schema(**_args) click to toggle source
# File lib/praxis/collection.rb, line 36
def self.as_json_schema(**_args)
  the_type = @attribute&.type || member_type
  {
    type: json_schema_type,
    items: the_type.as_json_schema
  }
end
domain_model() click to toggle source
# File lib/praxis/collection.rb, line 28
def self.domain_model
  @member_type.domain_model
end
json_schema_type() click to toggle source
# File lib/praxis/collection.rb, line 32
def self.json_schema_type
  :array
end
member_type(type = nil) click to toggle source
# File lib/praxis/collection.rb, line 19
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
of(type) click to toggle source
Calls superclass method
# File lib/praxis/collection.rb, line 7
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