module Sequel::Plugins::LazyAttributes::ClassMethods

  1. lib/sequel/plugins/lazy_attributes.rb


Public Instance

  1. freeze
  2. lazy_attributes

Public Instance methods


Freeze lazy attributes module when freezing model class.

[show source]
   # File lib/sequel/plugins/lazy_attributes.rb
42 def freeze
43   @lazy_attributes_module.freeze if @lazy_attributes_module
45   super
46 end

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.

[show source]
   # File lib/sequel/plugins/lazy_attributes.rb
51 def lazy_attributes(*attrs)
52   unless select = dataset.opts[:select]
53     select ={|c| Sequel.qualify(dataset.first_source, c)}
54   end
55   set_dataset(*select.reject{|c| attrs.include?(dataset.send(:_hash_key_symbol, c))}))
56   attrs.each{|a| define_lazy_attribute_getter(a)}
57 end