Discogs.Models.Record (discogs_shuffle v0.2.0) View Source
Ecto model representing a record belonging to a Discogs release.
This is not a first-class object in Discogs's data model. What this allows us
to do is to join over from User
-> Release
-> Record
and pick out a
sampling of specific records in a user's collection at random (for example,
disc 2 of a 2xLP set).
See Discogs.CLI.shuffle_collection/2
for example usage.
Link to this section Summary
Functions
Validates the params and returns an Ecto changeset on success.
Formats the Record
name for consumption by the Discogs.Repo
(or
elsewhere).
Link to this section Functions
Specs
changeset( %Discogs.Models.Record{ __meta__: term(), artists: term(), disc_number: term(), id: term(), inserted_at: term(), release: term(), release_id: term(), updated_at: term() }, %{optional(any()) => any()} ) :: Ecto.Changeset.t()
Validates the params and returns an Ecto changeset on success.
Specs
format_name( %Discogs.Models.Record{ __meta__: term(), artists: term(), disc_number: term(), id: term(), inserted_at: term(), release: term(), release_id: term(), updated_at: term() }, (... -> any()) ) :: String.t()
Formats the Record
name for consumption by the Discogs.Repo
(or
elsewhere).
If the record is part of a 2+xLP set, appends the disc number; else delegates to the release name.
TODO: This should be done by implementing String.Chars
.
cf. https://elixirschool.com/en/lessons/advanced/protocols/
This would allow us to:
- simply call the stringified value of the release, rather than passing around a formatter
- consume the stringfied value of the record similarly elsewhere (i.e., via simple interpolation without a method call).
This works similarly to defining #to_s
in Ruby.