View Source RDF.Resource.Generator behaviour (RDF.ex v2.0.1)

A configurable and customizable way to generate resource identifiers.

The basis are different implementations of the behaviour defined in this module for configurable resource identifier generation methods.

Generally two kinds of identifiers are differentiated:

  1. parameter-less identifiers which are generally random
  2. identifiers which are based on some value, where every attempt to create an identifier for the same value, should produce the same identifier

Not all implementations must support both kind of identifiers.

The RDF.Resource.Generator module provides two generate functions for the kindes of identifiers, generate/1 for random-based and generate/2 for value-based identifiers. The config keyword list they take must contain a :generator key, which provides the module implementing the RDF.Resource.Generator behaviour. All other keywords are specific to the generator implementation. When the generator is configured differently for the different identifier types, the identifier-type specific configuration can be put under the keys :random_based and :value_based respectively. The RDF.Resource.Generator.generate implementations will be called with the general configuration options from the top-level merged with the identifier-type specific configuration.

The generate functions however are usually not called directly. See the guide on how they are meant to be used.

The following RDF.Resource.Generator implementations are provided with RDF.ex:

Summary

Callbacks

Generates a random resource identifier based on the given config.

Generates a resource identifier based on the given config and value.

Allows to normalize the configuration.

Functions

Generates a random resource identifier based on the given config.

Generates a resource identifier based on the given config and value.

Types

@type id_type() :: :random_based | :value_based

Callbacks

@callback generate(config :: any()) :: RDF.Resource.t()

Generates a random resource identifier based on the given config.

@callback generate(config :: any(), value :: binary()) :: RDF.Resource.t()

Generates a resource identifier based on the given config and value.

Link to this callback

generator_config(id_type, keyword)

View Source
@callback generator_config(
  id_type(),
  keyword()
) :: any()

Allows to normalize the configuration.

This callback is optional. A default implementation is generated which returns the configuration as-is.

Functions

Generates a random resource identifier based on the given config.

See the guide on how it is meant to be used.

Generates a resource identifier based on the given config and value.

See the guide on how it is meant to be used.