lib/sequel/plugins/association_proxies.rb in sequel-3.11.0 vs lib/sequel/plugins/association_proxies.rb in sequel-3.12.0
- old
+ new
@@ -3,9 +3,17 @@
# 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.
+ #
+ # Usage:
+ #
+ # # Use association proxies in all model subclasses (called before loading subclasses)
+ # Sequel::Model.plugin :association_proxies
+ #
+ # # Use association proxies in a specific model subclass
+ # Album.plugin :association_proxies
module AssociationProxies
# A proxy for the association. Calling an array method will load the
# associated objects and call the method on the associated object array.
# Calling any other method will call that method on the association's dataset.
class AssociationProxy < BasicObject