Class Index [+]

Quicksearch

Sequel::Plugins::LazyAttributes::ClassMethods

Attributes

lazy_attributes_module[RW]

Module to store the lazy attribute getter methods, so they can be overridden and call super to get the lazy attribute behavior

Public Instance Methods

lazy_attributes(*attrs) click to toggle source

Remove the given attributes from the list of columns selected by default. For each attribute given, create an accessor method that allows a lazy lookup of the attribute. Each attribute should be given as a symbol.

    # File lib/sequel/plugins/lazy_attributes.rb, line 42
42:         def lazy_attributes(*attrs)
43:           set_dataset(dataset.select(*(columns - attrs)))
44:           attrs.each{|a| define_lazy_attribute_getter(a)}
45:         end

Private Instance Methods

define_lazy_attribute_getter(a) click to toggle source

Add a lazy attribute getter method to the lazy_attributes_module

    # File lib/sequel/plugins/lazy_attributes.rb, line 50
50:         def define_lazy_attribute_getter(a)
51:           include(self.lazy_attributes_module ||= Module.new) unless lazy_attributes_module
52:           lazy_attributes_module.class_eval do
53:             define_method(a) do
54:               if !values.include?(a) && !new?
55:                 lazy_attribute_lookup(a)
56:               else
57:                 super()
58:               end
59:             end
60:           end
61:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.