Sha256: f932935339588dad61d308268986675dcc3bf92308a819df227646eb9a317540

Contents?: true

Size: 989 Bytes

Versions: 3

Compression:

Stored size: 989 Bytes

Contents

module NxtSchema
  def schema(name = :root, **options, &block)
    Node::Schema.new(name: name, parent_node: nil, **options, &block)
  end

  def collection(name = :roots, **options, &block)
    Node::Collection.new(name: name, parent_node: nil, **options, &block)
  end

  def params(name = :root, **options, &block)
    Node::Schema.new(
      name: name,
      parent_node: nil,
      **options.merge(
        type_system: NxtSchema::Types::Params,
      ).reverse_merge(transform_keys: :to_sym),
      &block
    )
  end

  def json(name = :root, **options, &block)
    Node::Schema.new(
      name: name,
      parent_node: nil,
      **options.merge(
        type_system: NxtSchema::Types::JSON,
      ).reverse_merge(transform_keys: :to_sym),
      &block
    )
  end

  alias_method :node, :schema
  alias_method :root, :schema
  alias_method :nodes, :collection
  alias_method :roots, :collection

  module_function :root, :roots, :node, :nodes, :collection, :schema, :params
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nxt_schema-0.1.2 lib/nxt_schema/dsl.rb
nxt_schema-0.1.1 lib/nxt_schema/dsl.rb
nxt_schema-0.1.0 lib/nxt_schema/dsl.rb