Module MusicBrainz::Model::Relateable
In: lib/rbrainz/model/relateable.rb

Mixin module to add add advanced relationship capabilities to Entity classes.

see:Relation

Methods

Public Instance methods

Adds a Relation.

This method adds relation to the list of relations. The given relation has to be initialized, at least the target type has to be set.

Returns a list of Relation objects.

If target_type is given, only relations of that target type are returned. For MusicBrainz, the following target types are defined:

  • Relation::TO_ARTIST
  • Relation::TO_RELEASE
  • Relation::TO_TRACK
  • Relation::TO_URL

If target_type is Relation::TO_ARTIST, for example, this method returns all relations between this Entity and artists.

You may use the relation_type parameter to further restrict the selection. If it is set, only relations with the given relation type are returned. The required_attributes sequence lists attributes that have to be part of all returned relations.

If direction is set, only relations with the given reading direction are returned. You can use the Relation::DIR_FORWARD, Relation::DIR_BACKWARD, and Relation::DIR_BOTH constants for this.

Returns a list of target types available for this entity.

Use this to find out to which types of targets this entity has relations. If the entity only has relations to tracks and artists, for example, then a list containg the strings Relation::TO_TRACK and Relation::TO_ARTIST is returned.

[Validate]