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
Classes and Modules
Public Class methods
Configure the deprecated associations plugin. Options:
backtrace: Print backtrace with warning deduplicate: Set to false to emit warnings for every
deprecated association method call/access (when not caching associations, this is always false)
raise: Raise Sequel::Plugin::DeprecatedAssociations::Access
instead of warning
# File lib/sequel/plugins/deprecated_associations.rb 56 def self.configure(model, opts = OPTS) 57 model.instance_exec do 58 (@deprecated_associations_config ||= {}).merge!(opts) 59 end 60 end