class SchemaTest::Property
Attributes
description[R]
name[R]
optional[R]
type[R]
Public Class Methods
new(name, type, description=nil)
click to toggle source
# File lib/schema_test/property.rb, line 5 def initialize(name, type, description=nil) @name = name @type = type @description = description @optional = false end
Public Instance Methods
==(other)
click to toggle source
# File lib/schema_test/property.rb, line 27 def ==(other) name == other.name && type == other.type && description == other.description && optional == other.optional end
as_json_schema()
click to toggle source
# File lib/schema_test/property.rb, line 20 def as_json_schema json_schema = { 'type' => json_schema_type } json_schema['description'] = description if description json_schema['format'] = json_schema_format if json_schema_format { name.to_s => json_schema } end
as_structure(_=nil)
click to toggle source
# File lib/schema_test/property.rb, line 12 def as_structure(_=nil) if @optional { name => nil } else name end end
json_schema_format()
click to toggle source
# File lib/schema_test/property.rb, line 46 def json_schema_format nil end
json_schema_type()
click to toggle source
# File lib/schema_test/property.rb, line 42 def json_schema_type @type.to_s end
optional!()
click to toggle source
# File lib/schema_test/property.rb, line 38 def optional! @optional = true end
optional?()
click to toggle source
# File lib/schema_test/property.rb, line 34 def optional? optional end