Module | Sequel::Plugins::LazyAttributes::ClassMethods |
In: |
lib/sequel/plugins/lazy_attributes.rb
|
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 |
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 46 46: def lazy_attributes(*attrs) 47: unless select = dataset.opts[:select] 48: select = dataset.columns.map{|c| Sequel.qualify(dataset.first_source, c)} 49: end 50: set_dataset(dataset.select(*select.reject{|c| attrs.include?(dataset.send(:_hash_key_symbol, c))})) 51: attrs.each{|a| define_lazy_attribute_getter(a)} 52: end