Dymo v0.1.3 Dymo.Tagger behaviour View Source

Defines the functions required for a tagger to be compabible with the Dymo.Taggable macro.

Link to this section Summary

Types

A join key is an atom

A join table name is a string

A single label is a string

Either a single label or a list of them

A list of labels

Functions

A helper function that helps computing the field name to use in taggings queries

A helper function that generates the join table name to be used for a given schema or model

Callbacks

Adds labels to a given instance of a model

Queries models that are tagged with the given labels

Queries models that are tagged with the given labels

Retrieves labels associated with an target. The target could be either a module or a schema

Retrieves labels associated with an target

Removes labels from a given instance of a model

Sets the labels associated with an instance of a model

Link to this section Types

Link to this type join_key() View Source
join_key() :: atom()

A join key is an atom.

Link to this type join_table() View Source
join_table() :: String.t()

A join table name is a string.

A single label is a string.

Link to this type label_or_labels() View Source
label_or_labels() :: label() | labels()

Either a single label or a list of them.

A list of labels.

Link to this section Functions

Link to this function join_key(module) View Source
join_key(Ecto.Schema.t() | module() | String.t()) :: atom()

A helper function that helps computing the field name to use in taggings queries.

Examples

iex> Tagger.join_key(Dymo.Post)
:post_id

iex> Tagger.join_key(%Dymo.Post{})
:post_id

iex> Tagger.join_key(Person)
:person_id
Link to this function join_table(module) View Source
join_table(Ecto.Schema.t() | module() | String.t()) :: String.t()

A helper function that generates the join table name to be used for a given schema or model.

Examples

iex> Tagger.join_table(Dymo.Post)
"posts_tags"

iex> Tagger.join_table(%Dymo.Post{})
"posts_tags"

iex> Tagger.join_table(Person)
"people_tags"
Link to this function singularize(target) View Source
singularize(Ecto.Schema.t() | module() | String.t()) :: String.t()

Link to this section Callbacks

Link to this callback add_labels(arg0, label_or_labels) View Source

Adds labels to a given instance of a model.

See Dymo.TaggerImpl.add_labels/2.

Link to this callback query_labeled_with(module, label_or_labels) View Source
query_labeled_with(module(), label_or_labels()) :: Ecto.Query.t()

Queries models that are tagged with the given labels.

See Dymo.query_labeled_with.query_labels/2.

Link to this callback query_labeled_with(module, label_or_labels, join_table, join_key) View Source
query_labeled_with(module(), label_or_labels(), join_table(), join_key()) ::
  Ecto.Query.t()

Queries models that are tagged with the given labels.

See Dymo.query_labeled_with.query_labels/4.

Link to this callback query_labels(arg0) View Source
query_labels(module() | String.t() | Ecto.Schema.t()) :: Ecto.Query.t()

Retrieves labels associated with an target. The target could be either a module or a schema.

See Dymo.TaggerImpl.query_labels/1.

Link to this callback query_labels(arg0, join_table, join_key) View Source
query_labels(Ecto.Schema.t(), join_table(), join_key()) :: Ecto.Query.t()

Retrieves labels associated with an target.

See Dymo.TaggerImpl.query_labels/3.

Link to this callback remove_labels(arg0, label_or_labels) View Source
remove_labels(Ecto.Schema.t(), label_or_labels()) :: Ecto.Schema.t()

Removes labels from a given instance of a model.

See Dymo.TaggerImpl.remove_labels/2.

Link to this callback set_labels(arg0, label_or_labels) View Source

Sets the labels associated with an instance of a model.

If any other labels are associated to the given model, they are discarded if they are not part of the list of passed new labels.

See Dymo.TaggerImpl.set_labels/2.