resx v0.1.2 Resx.Transformer behaviour

A transformer is a referenceable interface for performing reproducible modifications on resources.

A module that implements the transformer behaviour becomes usable by the Resx.Producers.Transform producer.

Link to this section Summary

Functions

Apply a transformation to a resource

Apply a transformation to a resource

Callbacks

Implement the behaviour to transform a resource

Link to this section Functions

Link to this function apply!(resource, transformer, opts \\ [])

Apply a transformation to a resource.

Raises a Resx.Transformer.TransformError if the transformation cannot be applied.

For more details see apply/2.

Link to this function apply(resource, transformer, opts \\ [])
apply(Resx.Resource.t(), module(), keyword()) ::
  {:ok, Resx.Resource.t()} | Resx.error()

Apply a transformation to a resource.

A transformer must be a module that implements the Resx.Transformer behaviour.

Link to this section Callbacks

Link to this callback transform(resource, options)
transform(resource :: Resx.Resource.t(), options :: keyword()) ::
  {:ok, resource :: Resx.Resource.t()} | Resx.error()

Implement the behaviour to transform a resource.

The options keyword allows for your implementation to expose some configurable settings.

If the transformation was successful return { :ok, resource }, where resource is the newly transformed resource. Otherwise return an appropriate error.