class SchemaTest::Property::Array

Attributes

item_type[R]

Public Class Methods

new(name, of=nil, description=nil, &block) click to toggle source
Calls superclass method
# File lib/schema_test/property.rb, line 242
def initialize(name, of=nil, description=nil, &block)
  super(name, :array, description)
  if block_given?
    @item_type = AnonymousObject.new(&block)
  else
    @item_type = of
  end
  # @items = { type: @item_type }
end

Public Instance Methods

==(other) click to toggle source
Calls superclass method
# File lib/schema_test/property.rb, line 252
def ==(other)
  super && @item_type == other.item_type
end
as_json_schema() click to toggle source
Calls superclass method
# File lib/schema_test/property.rb, line 264
def as_json_schema
  super.tap do |json_schema|
    item_schema = @item_type.is_a?(SchemaTest::Property) ? @item_type.as_json_schema(false) : { 'type' => @item_type.to_s }
    json_schema[name.to_s]['items'] = item_schema
  end
end
as_structure(_=nil) click to toggle source
# File lib/schema_test/property.rb, line 256
def as_structure(_=nil)
  if @item_type.is_a?(SchemaTest::Property)
    { name => @item_type.as_structure(false) }
  else
    { name => [] }
  end
end