blogit v1.2.3 Blogit.RepositoryProviders.Memory View Source

This module implements the Blogit.RepositoryProvider behaviour.

It provides in-memory repository access which can be used for testing.

The repository is just an Agent process, so messages could be sent to it in order to add or remove data to or from it.

Link to this section Summary

Functions

Stores a file in the in-memory repository. Returns the state of the in-memory repository before the addition.

Adds a file to the in-memory repository using the given file_path as path to the file to create and the given data as its contents.

Deletes a file from the in-memory repository. Returns the state of the repository before the modification.

Callback implementation for Blogit.RepositoryProvider.fetch/1.

Replaces an existing file's content with new content. If the file doesn't exist, creates it. Returns the state of the repository before the modification.

Starts the memory repository as a process. The process is named and its name is the name of this module.

Stops the in-memory repository process.

Link to this section Types

Link to this section Functions

Link to this function

add_file(file)

View Source
add_file(Blogit.RepositoryProviders.Memory.File.t()) :: t()

Stores a file in the in-memory repository. Returns the state of the in-memory repository before the addition.

Link to this function

add_file(file_path, data)

View Source
add_file(String.t(), term()) :: t()

Adds a file to the in-memory repository using the given file_path as path to the file to create and the given data as its contents.

Returns the state of the repository before the modification.

Link to this function

delete_file(file_path)

View Source
delete_file(String.t()) :: t()

Deletes a file from the in-memory repository. Returns the state of the repository before the modification.

Callback implementation for Blogit.RepositoryProvider.fetch/1.

Callback implementation for Blogit.RepositoryProvider.file_in?/1.

Callback implementation for Blogit.RepositoryProvider.file_info/2.

Callback implementation for Blogit.RepositoryProvider.list_files/1.

Callback implementation for Blogit.RepositoryProvider.local_path/0.

Link to this function

read_file(file_name, folder \\ "")

View Source

Callback implementation for Blogit.RepositoryProvider.read_file/2.

Link to this function

replace_file(file)

View Source
replace_file(Blogit.RepositoryProviders.Memory.File.t()) :: t()

Replaces an existing file's content with new content. If the file doesn't exist, creates it. Returns the state of the repository before the modification.

Callback implementation for Blogit.RepositoryProvider.repository/0.

Link to this function

start_link(data \\ %Blogit.RepositoryProviders.Memory{})

View Source
start_link(t()) :: {:ok, pid()} | {:error, term()}

Starts the memory repository as a process. The process is named and its name is the name of this module.

Accepts argument of type Blogit.RepositoryProviders.Memory.t. By default the repository is empty.

Stops the in-memory repository process.