Sha256: 863a99802b4401920ccb8c4ceeb215ded45fab92f49d9d4f27617529945abde5

Contents?: true

Size: 495 Bytes

Versions: 1

Compression:

Stored size: 495 Bytes

Contents

module NxtSchema
  module Node
    class Collection < Node::Base
      include HasSubNodes

      DEFAULT_TYPE = NxtSchema::Types::Strict::Array

      def initialize(name:, type: DEFAULT_TYPE, parent_node:, **options, &block)
        super
      end

      private

      def add_sub_node(node)
        # TODO: Spec that this raises
        raise ArgumentError, "It's not possible to define multiple nodes within a collection" unless sub_nodes.empty?

        super
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nxt_schema-1.0.0 lib/nxt_schema/node/collection.rb