Module: Textus::Hooks::Loader

Defined in:
lib/textus/hooks/loader.rb

Class Method Summary collapse

Class Method Details

.current_registryObject



15
16
17
18
# File 'lib/textus/hooks/loader.rb', line 15

def self.current_registry
  Thread.current[THREAD_REGISTRY_KEY] or
    raise UsageError.new("no active registry; hook code must be loaded by a Store")
end

.with_registry(registry) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/textus/hooks/loader.rb', line 7

def self.with_registry(registry)
  prev = Thread.current[THREAD_REGISTRY_KEY]
  Thread.current[THREAD_REGISTRY_KEY] = registry
  yield
ensure
  Thread.current[THREAD_REGISTRY_KEY] = prev
end