thesis v0.0.18 Thesis.PageContent

Summary

Functions

Selects the right page content from a list

Returns a keyword list of meta attributes from the serialized data.

Doctests

Returns a serialized string, given a map, for storage in the meta field

Types

t :: %Thesis.PageContent{__meta__: term, content: String.t | nil, content_type: String.t | nil, id: any, inserted_at: any, meta: String.t | nil, name: String.t, page: term, page_id: integer, updated_at: any}

Functions

find(contents, page_id, name)

Selects the right page content from a list.

iex> foo = [%Thesis.PageContent{id: 1, page_id: nil, name: "Test"},%Thesis.PageContent{id: 2, page_id: 1, name: "Test"},%Thesis.PageContent{id: 3, page_id: 2, name: "Test"},%Thesis.PageContent{id: 4, page_id: nil, name: "Test2"},%Thesis.PageContent{id: 5, page_id: 1, name: "Test2"}]
iex> Thesis.PageContent.find(foo, nil, "Test").id == 1
true
iex> Thesis.PageContent.find(foo, 1, "Test").id == 2
true
iex> Thesis.PageContent.find(foo, 2, "Test").id == 3
true
iex> Thesis.PageContent.find(foo, nil, "Test2").id == 4
true
iex> Thesis.PageContent.find(foo, 1, "Test2").id == 5
true
iex> Thesis.PageContent.find(foo, 1, "Test7")
nil
meta_attributes(page_content)

Returns a keyword list of meta attributes from the serialized data.

Doctests:

iex> m = %Thesis.PageContent{meta: ~S({"test":"Thing", "test2":"123"})}
iex> Thesis.PageContent.meta_attributes(m)
%{test: "Thing", test2: "123"}
meta_serialize(keyword_list)

Returns a serialized string, given a map, for storage in the meta field.

Doctests:

iex> m = %{test: "Thing", test2: "123"}
iex> Thesis.PageContent.meta_serialize(m)
~S({"test2":"123","test":"Thing"})