Class: Sequel::Plugins::AssociationProxies::AssociationProxy

Class | Sequel::Plugins::AssociationProxies::AssociationProxy
In: | lib/sequel/plugins/association_proxies.rb
Parent: | BasicObject

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.

### Methods

method_missing new

### Constants

ARRAY | = | [] |  | Empty array used to check if an array responds to the given method.

### Public Class methods

new(instance, reflection, reload=nil)

Set the association reflection to use, and whether the association should be reloaded if an array method is called.

[Source]

        # File lib/sequel/plugins/association_proxies.rb, line 18
    18:         def initialize(instance, reflection, reload=nil)
    19:           @instance = instance
    20:           @reflection = reflection
    21:           @reload = reload
    22:         end

### Public Instance methods

method_missing(meth, *args, &block)

Call the method given on the array of associated objects if the method is an array method, otherwise call the method on the association‘s dataset.

[Source]

        # File lib/sequel/plugins/association_proxies.rb, line 26
    26:         def method_missing(meth, *args, &block)
    27:           (ARRAY.respond_to?(meth) ? @instance.send(:load_associated_objects, @reflection, @reload) : @instance.send(@reflection.dataset_method)).
    28:             send(meth, *args, &block)
    29:         end

[Validate]