PolyPost.Resource behaviour (poly_post v0.2.0)

Copy Markdown View Source

A behavior used to transform a resource (like a markdown file) into structured content.

Summary

Types

The config for a resource

The content belonging to an item (includes key)

The unique ID for an item belonging to a resource

Name of an existing resource

The raw content belonging to a resource

The raw metadata belonging to a resource

Callbacks

Defines a way to return the desired content from the resource.

Types

config()

@type config() :: keyword()

The config for a resource

content()

@type content() :: %{key: key()}

The content belonging to an item (includes key)

key()

@type key() :: term()

The unique ID for an item belonging to a resource

name()

@type name() :: atom()

Name of an existing resource

raw_content()

@type raw_content() :: binary()

The raw content belonging to a resource

raw_metadata()

@type raw_metadata() :: binary()

The raw metadata belonging to a resource

Callbacks

build(reference, metadata, body)

(since 0.1.0)
@callback build(reference :: String.t(), metadata :: Keyword.t(), body :: String.t()) ::
  content()

Defines a way to return the desired content from the resource.

This MAY return other keys but MUST have have a key named key.