Module to store the lazy attribute getter methods, so they can be overridden and call super to get the lazy attribute behavior
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 39 def lazy_attributes(*attrs) set_dataset(dataset.select(*(columns - attrs))) attrs.each{|a| define_lazy_attribute_getter(a)} end
Add a lazy attribute getter method to the #lazy_attributes_module
# File lib/sequel/plugins/lazy_attributes.rb, line 47 def define_lazy_attribute_getter(a) include(self.lazy_attributes_module ||= Module.new) unless lazy_attributes_module lazy_attributes_module.class_eval do define_method(a) do if !values.has_key?(a) && !new? lazy_attribute_lookup(a) else super() end end end end