Dymo v0.3.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
Functions
Use this module to implements alternative Ecto.Tagger
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
Generates query for retrieving labels associated with a schema
Queries models that are tagged with the given labels
Generates query for retrieving labels associated with a schema’s instance
Removes labels from a given instance of a model
Sets the labels associated with an instance of a model
Link to this section Types
A join key is an atom.
A join table name is a string.
Link to this section Functions
Use this module to implements alternative Ecto.Tagger
By default, all functions are delegated to Ecto.Tagger
but can be overriden
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
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"
singularize(Ecto.Schema.t() | module() | String.t()) :: String.t()
Link to this section Callbacks
add_labels(Ecto.Schema.t(), Dymo.Tag.label_or_labels()) :: Ecto.Schema.t()
Adds labels to a given instance of a model.
See Dymo.TaggerImpl.add_labels/{2,3}
.
add_labels(Ecto.Schema.t(), Dymo.Tag.ns(), Dymo.Tag.label_or_labels()) :: Ecto.Schema.t()
query_all_labels(join_table(), join_key()) :: Ecto.Query.t()
Generates query for retrieving labels associated with a schema.
See Dymo.TaggerImpl.query_all_labels/{2,3}
.
query_all_labels(join_table(), join_key(), Dymo.Tag.ns()) :: Ecto.Query.t()
query_labeled_with(module(), Dymo.Tag.tag_or_tags(), join_table(), join_key()) :: Ecto.Query.t()
Queries models that are tagged with the given labels.
See Dymo.query_labeled_with.query_labels/4
.
query_labels(Ecto.Schema.t(), join_table(), join_key()) :: Ecto.Query.t()
Generates query for retrieving labels associated with a schema’s instance.
See Dymo.TaggerImpl.query_labels/{3,4}
.
query_labels(Ecto.Schema.t(), join_table(), join_key(), Dymo.Tag.ns()) :: Ecto.Query.t()
remove_labels(Ecto.Schema.t(), Dymo.Tag.label_or_labels()) :: Ecto.Schema.t()
Removes labels from a given instance of a model.
See Dymo.TaggerImpl.remove_labels/{2,3}
.
remove_labels(Ecto.Schema.t(), Dymo.Tag.ns(), Dymo.Tag.label_or_labels()) :: Ecto.Schema.t()
set_labels(Ecto.Schema.t(), Dymo.Tag.label_or_labels()) :: Ecto.Schema.t()
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,3}
.
set_labels(Ecto.Schema.t(), Dymo.Tag.ns(), Dymo.Tag.label_or_labels()) :: Ecto.Schema.t()