Module: Sequel::Plugins::LazyAttributes::ClassMethods
- Defined in:
- lib/sequel/plugins/lazy_attributes.rb
Instance Method Summary collapse
-
#freeze ⇒ Object
Freeze lazy attributes module when freezing model class.
-
#lazy_attributes(*attrs) ⇒ Object
Remove the given attributes from the list of columns selected by default.
- #lazy_attributes_module ⇒ Object
- #lazy_attributes_module=(v) ⇒ Object
Instance Method Details
#freeze ⇒ Object
Freeze lazy attributes module when freezing model class.
51 52 53 54 55 |
# File 'lib/sequel/plugins/lazy_attributes.rb', line 51 def freeze @lazy_attributes_module.freeze if @lazy_attributes_module super end |
#lazy_attributes(*attrs) ⇒ Object
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.
60 61 62 63 64 65 66 |
# File 'lib/sequel/plugins/lazy_attributes.rb', line 60 def lazy_attributes(*attrs) unless select = dataset.opts[:select] select = dataset.columns.map{|c| Sequel.qualify(dataset.first_source, c)} end set_dataset(dataset.select(*select.reject{|c| attrs.include?(dataset.send(:_hash_key_symbol, c))})) attrs.each{|a| define_lazy_attribute_getter(a)} end |
#lazy_attributes_module ⇒ Object
41 42 43 44 |
# File 'lib/sequel/plugins/lazy_attributes.rb', line 41 def lazy_attributes_module Sequel::Deprecation.deprecate('Sequel::Model.lazy_attributes_module', 'There is no replacement') @lazy_attributes_module end |
#lazy_attributes_module=(v) ⇒ Object
45 46 47 48 |
# File 'lib/sequel/plugins/lazy_attributes.rb', line 45 def lazy_attributes_module=(v) Sequel::Deprecation.deprecate('Sequel::Model.lazy_attributes_module=', 'There is no replacement') @lazy_attributes_module= v end |