Module: Plushie::UI::MemoCache Private

Defined in:
lib/plushie/ui.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Thread-local memo cache used during tree normalization. The runtime seeds the previous cache before normalize and captures the new cache after.

Class Method Summary collapse

Class Method Details

.captureObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Capture and clear the current cache (called by runtime after normalize).



82
83
84
85
86
87
# File 'lib/plushie/ui.rb', line 82

def self.capture
  result = Thread.current[:_plushie_memo_current] || {}
  Thread.current[:_plushie_memo_current] = nil
  Thread.current[:_plushie_memo_prev] = nil
  result
end

.currentHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the current render's memo cache (being built).

Returns:

  • (Hash)

    the current render's memo cache (being built)



71
# File 'lib/plushie/ui.rb', line 71

def self.current = Thread.current[:_plushie_memo_current] || {}

.prevHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the previous render's memo cache.

Returns:

  • (Hash)

    the previous render's memo cache



68
# File 'lib/plushie/ui.rb', line 68

def self.prev = Thread.current[:_plushie_memo_prev] || {}

.seed(cache) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Set the previous cache (called by runtime before normalize).



74
# File 'lib/plushie/ui.rb', line 74

def self.seed(cache) = Thread.current[:_plushie_memo_prev] = cache

.store(key, value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Store a memo result in the current cache.



77
78
79
# File 'lib/plushie/ui.rb', line 77

def self.store(key, value)
  (Thread.current[:_plushie_memo_current] ||= {})[key] = value
end