Module: Sequel::Plugins::AssociationProxies

Defined in:

lib/sequel/plugins/association_proxies.rb

Overview

Sequel by default does not use proxies for associations. The association
method for *_to_many associations returns an array, and the
association_dataset method returns a dataset. This plugin makes the
association method return a proxy that will load the association and call a
method on the association array if sent an array method, and otherwise send
the method to the association's dataset.

You can override which methods to forward to the dataset by passing a block
to the plugin:

If the block returns false or nil, the method is sent to the array of
associated objects. Otherwise, the method is sent to the association
dataset. Here are the entries in the hash passed to the block:

# Use association proxies in all model subclasses (called before loading subclasses)Sequel::Model.plugin:association_proxies# Use association proxies in a specific model subclassAlbum.plugin:association_proxies