module Sequel::Plugins::DeprecatedAssociations

The deprecated_associations plugin adds support for deprecating associations. Attempts to use association methods and access association metadata for deprecated associations results in a warning.

Album.plugin :deprecated_associations
Album.many_to_one :artist, deprecated: true
album = Album[1]

# Warnings for all of the following calls
album.artist
album.artist_dataset
album.artist = Artist[2]
Album.association_reflection(:artist)
Album.eager(:artist)
Album.eager_graph(:artist)
Album.where(artist: Artist[1]).all

By default, the plugin issues a single warning per association method or association reflection. See DeprecatedAssociations.configure for options to make deprecated association issue warnings for every access, to include backtraces in warnings, or to raise an exception instead of warning.

Note that Model.association_reflections and Model.all_association_reflections will include deprecated associations, and accessing the metadata for deprecated associations through these interfaces not issue warnings.

Usage:

# Make all models support deprecated associations
# (called before loading subclasses)
Sequel::Model.plugin :deprecated_associations

# Make Album class support deprecated associations
Album.plugin :deprecated_associations