Module: ArLazyPreload::Base

Defined in:
lib/ar_lazy_preload/ext/base.rb

Overview

ActiveRecord::Base patch with lazy preloading support

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#lazy_preload_contextObject

Returns the value of attribute lazy_preload_context.



10
11
12
# File 'lib/ar_lazy_preload/ext/base.rb', line 10

def lazy_preload_context
  @lazy_preload_context
end

Class Method Details

.included(base) ⇒ Object



6
7
8
# File 'lib/ar_lazy_preload/ext/base.rb', line 6

def self.included(base)
  base.class.delegate :lazy_preload, to: :all
end

Instance Method Details

#try_preload_lazily(association_name) ⇒ Object

When context has been set, this method would cause preloading association with a given name



13
14
15
# File 'lib/ar_lazy_preload/ext/base.rb', line 13

def try_preload_lazily(association_name)
  lazy_preload_context.try_preload_lazily(association_name) if lazy_preload_context.present?
end