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
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.
Generated with the Darkfish Rdoc Generator 1.1.6.