Module | Sequel::Plugins::LazyAttributes
In: | lib/sequel/plugins/lazy_attributes.rb

The lazy_attributes plugin allows users to easily set that some attributes should not be loaded by default when loading model objects. If the attribute is needed after the instance has been retrieved, a database query is made to retreive the value of the attribute.

This plugin depends on the identity_map and tactical_eager_loading plugin, and allows you to eagerly load lazy attributes for all objects retrieved with the current object. So the following code should issue one query to get the albums and one query to get the reviews for all of those albums:

      Album.plugin :lazy_attributes, :review
      Sequel::Model.with_identity_map do
        Album.filter{id<100}.all do |a|
          a.review
        end
      end

      # You can specify multiple columns to lazily load:
      Album.plugin :lazy_attributes, :review, :tracklist

### Methods

apply configure

### Classes and Modules

Module Sequel::Plugins::LazyAttributes::ClassMethods
Module Sequel::Plugins::LazyAttributes::InstanceMethods

### Public Class methods

apply(model, *attrs)

Lazy attributes requires the identity map and tactical eager loading plugins

[Source]

        # File lib/sequel/plugins/lazy_attributes.rb, line 24
    24:       def self.apply(model, *attrs)
    25:         model.plugin :identity_map
    26:         model.plugin :tactical_eager_loading
    27:       end

configure(model, *attrs)

Set the attributes given as lazy attributes

[Source]

        # File lib/sequel/plugins/lazy_attributes.rb, line 30
    30:       def self.configure(model, *attrs)
    31:         model.lazy_attributes(*attrs) unless attrs.empty?
    32:       end

[Validate]