Class: ArLazyPreload::Contexts::TemporaryPreloadConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/ar_lazy_preload/contexts/temporary_preload_config.rb

Overview

Preload config that used to enable preloading only for specfic part of the application

Constant Summary collapse

THREAD_KEY =
"temporary_preload_context_enabled"

Class Method Summary collapse

Class Method Details

.enabled?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/ar_lazy_preload/contexts/temporary_preload_config.rb', line 10

def enabled?
  Thread.current[THREAD_KEY] == true
end

.within_contextObject



14
15
16
17
18
19
# File 'lib/ar_lazy_preload/contexts/temporary_preload_config.rb', line 14

def within_context
  Thread.current[THREAD_KEY] = true
  yield
ensure
  Thread.current[THREAD_KEY] = nil
end