View Source Eakins.UseCases.Reflection behaviour (eakins v0.0.1)

Abstracting operations across our image storage types

Link to this section Summary

Callbacks

Creates a changeset that updates an image with the given key in the provided schema

Creates a changeset that deletes the image with the given key

Finds an image in an image container

Returns true if the image container has the image with the given key

Removes the given image from the underlying storage mechanism

Updates the image in the image container

Link to this section Types

@type container_name() :: String.t()

Link to this section Callbacks

Link to this callback

add_or_update_image(t, t, key, any)

View Source
@callback add_or_update_image(Eakins.Schema.t(), String.t(), Eakins.key(), any()) ::
  Ecto.Changeset.t()

Creates a changeset that updates an image with the given key in the provided schema

Link to this callback

delete_image(t, t, t, key)

View Source
@callback delete_image(Eakins.Schema.t(), String.t(), Ecto.Changeset.t(), Image.key()) ::
  Ecto.Changeset.t()

Creates a changeset that deletes the image with the given key

Link to this callback

find_image(t, container_name, key)

View Source
@callback find_image(Eakins.Schema.t(), container_name(), Images.key()) ::
  Images.image() | nil

Finds an image in an image container

@callback has_image?(Eakins.Schema.t(), String.t(), Image.key()) :: boolean()

Returns true if the image container has the image with the given key

Link to this callback

remove_image_from_storage(t, t, image)

View Source
@callback remove_image_from_storage(Eakins.Schema.t(), String.t(), Images.image()) ::
  :ok | {:error, any()}

Removes the given image from the underlying storage mechanism

Link to this callback

update_image(t, t, t, image)

View Source
@callback update_image(Eakins.Schema.t(), String.t(), Ecto.Changeset.t(), Images.image()) ::
  Ecto.Changeset.t()

Updates the image in the image container

Link to this section Functions

Link to this function

add_or_update_image(schema, container_name, image_key, uploaded_image)

View Source
@spec add_or_update_image(Eakins.Schema.t(), String.t(), Eakins.key(), any()) ::
  Ecto.Changeset.t()
Link to this function

delete_image(schema, container_name, changeset, image_key)

View Source
@spec delete_image(Eakins.Schema.t(), String.t(), Ecto.Changeset.t(), Image.key()) ::
  Ecto.Changeset.t()
Link to this function

find_image(schema, container_name, image_key)

View Source
@spec find_image(Eakins.Schema.t(), String.t(), Images.key()) :: Images.image() | nil
Link to this function

has_image?(schema, container_name, image_key)

View Source
@spec has_image?(Eakins.Schema.t(), String.t(), Image.key()) :: boolean()
Link to this function

remove_image_from_storage(schema, container_name, old_image)

View Source
@spec remove_image_from_storage(Eakins.Schema.t(), String.t(), Images.image()) ::
  :ok | {:error, any()}
Link to this function

update_image(schema, container_name, changeset, new_image)

View Source
@spec update_image(Eakins.Schema.t(), String.t(), Ecto.Changeset.t(), Images.image()) ::
  Ecto.Changeset.t()