Class: Rubernate::LazyLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/rubernate/lazyload.rb

Overview

Base class and default implementation for lazy loaders. Loads each objects separately.

Direct Known Subclasses

HolderLazyLoader, ParamLazyLoader

Instance Method Summary collapse

Instance Method Details

#create(obj_pk, p_name) ⇒ Object

Creates LazyLoader

  • obj_pk - object that holds reference to object that is supposed to be load lazily.

  • p_name - name of reference(or collection) parameter that referes to object that is to be loaded lazily.



12
13
14
# File 'lib/rubernate/lazyload.rb', line 12

def create obj_pk, p_name
  @@single_lazy_loader
end

#load_lazy(obj) ⇒ Object



5
6
7
8
# File 'lib/rubernate/lazyload.rb', line 5

def load_lazy obj
  Rubernate::Log.debug {"load-lazy, pk: #{obj.primary_key}"}
  Rubernate.runtime.find_by_pk obj.primary_key, true
end