Sha256: 3570c139be85d059b451e4e899f31876354a7a1c5506a8d1f1ab76eed4e71493

Contents?: true

Size: 739 Bytes

Versions: 9

Compression:

Stored size: 739 Bytes

Contents

module Schemacop
  module V3
    class ObjectNode < Node
      def self.allowed_options
        super + %i[classes strict]
      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

9 entries across 9 versions & 1 rubygems

Version Path
schemacop-3.0.16 lib/schemacop/v3/object_node.rb
schemacop-3.0.15 lib/schemacop/v3/object_node.rb
schemacop-3.0.14 lib/schemacop/v3/object_node.rb
schemacop-3.0.13 lib/schemacop/v3/object_node.rb
schemacop-3.0.12 lib/schemacop/v3/object_node.rb
schemacop-3.0.11 lib/schemacop/v3/object_node.rb
schemacop-3.0.10 lib/schemacop/v3/object_node.rb
schemacop-3.0.9 lib/schemacop/v3/object_node.rb
schemacop-3.0.8 lib/schemacop/v3/object_node.rb