Method: ElasticGraph.define_schema

Defined in:
lib/elastic_graph/schema_definition/api.rb

.define_schemaObject

The main entry point for schema definition from ElasticGraph applications.

Call this API from a Ruby file configured as the ‘path_to_schema` (or from a Ruby file `load`ed from the `path_to_schema` file).

Examples:

ElasticGraph.define_schema do |schema|
  # The `schema` object provides the schema definition API. Use it in this block.
end


26
27
28
29
30
31
32
33
# File 'lib/elastic_graph/schema_definition/api.rb', line 26

def self.define_schema
  if (api_instance = ::Thread.current[:ElasticGraph_SchemaDefinition_API_instance])
    yield api_instance
  else
    raise Errors::SchemaError, "No active `SchemaDefinition::API` instance is available. " \
      "Let ElasticGraph load the schema definition files."
  end
end