Module: Ask::Schema::Helpers

Defined in:
lib/ask/schema/helpers.rb

Overview

Convenience helpers for creating schemas in a top-level context.

Instance Method Summary collapse

Instance Method Details

#schema(name = nil, description: nil, &block) ⇒ Schema

Create a new schema instance using a DSL block.

Parameters:

  • name (String, nil) (defaults to: nil)

    Schema name

  • description (String, nil) (defaults to: nil)

    Schema description

  • block (Proc)

    DSL block with type definitions

Returns:

  • (Schema)

    A new schema instance



13
14
15
16
# File 'lib/ask/schema/helpers.rb', line 13

def schema(name = nil, description: nil, &block)
  schema_class = Ask::Schema.create(&block)
  schema_class.new(name, description: description)
end