Sha256: a454e41cb1937dec246d3c6c9bf89d492d8070c202a9d6f973e391b67056b8db
Contents?: true
Size: 869 Bytes
Versions: 14
Compression:
Stored size: 869 Bytes
Contents
module Schemacop module V3 class ObjectNode < Node def self.allowed_options super + %i[classes strict] end def self.create(classes, **options, &block) options[:classes] = classes super(**options, &block) end def as_json {} # Not supported by Json Schema end protected def allowed_types Hash[@classes.map { |c| [c, c.name] }] end def init @classes = Array(options.delete(:classes) || []) @strict = options.delete(:strict) @strict = true if @strict.nil? end def type_assertion_method @strict ? :instance_of? : :is_a? end def validate_self unless @strict.is_a?(TrueClass) || @strict.is_a?(FalseClass) fail 'Option "strict" must be a "boolean".' end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems