Alembic v2.1.0 Alembic.Meta

Where specified, a meta member can be used to include non-standard meta-information. The value of each meta member MUST be an object (a “meta object”).

JSON API - Document Structure - Meta Information

Summary

Functions

Converts raw JSON to a “meta object”

Types

Functions

from_json(json, error_template)

Specs

from_json(Alembic.json_object, Alembic.Error.t) :: {:ok, map}
from_json(nil, Alembic.Error.t) :: {:ok, nil}
from_json(true | false | list | float | integer | String.t, Alembic.Error.t) :: Alembic.FromJson.error

Converts raw JSON to a “meta object”

“meta objects” have no defined fields, so all keys remain unchanged.

iex> Alembic.Meta.from_json(
...>   %{"copyright" => "© 2015"},
...>   %Alembic.Error{
...>     source: %Alembic.Source{
...>       pointer: "/meta"
...>     }
...>   }
...> )
{:ok, %{"copyright" => "© 2015"}}

The value of each meta member MUST be an object (a “meta object”).

JSON API - Document Structure - Meta Information

iex> Alembic.Meta.from_json(
...>   "© 2015",
...>   %Alembic.Error{
...>     source: %Alembic.Source{
...>       pointer: "/meta"
...>     }
...>   }
...> )
{
  :error,
  %Alembic.Document{
    errors: [
      %Alembic.Error{
        detail: "`/meta` type is not meta object",
        meta: %{
          "type" => "meta object"
        },
        source: %Alembic.Source{
          pointer: "/meta"
        },
        status: "422",
        title: "Type is wrong"
      }
    ]
  }
}

However, meta is optional in most locations, so nil is also allowed

iex> Alembic.Meta.from_json(
...>   nil,
...>   %Alembic.Error{
...>     source: %Alembic.Source{
...>       pointer: "/meta"
...>     }
...>   }
...> )
{:ok, nil}