Class: Rhales::HydrationRegistry
- Inherits:
-
Object
- Object
- Rhales::HydrationRegistry
- Defined in:
- lib/rhales/hydration_registry.rb
Overview
Registry to track window attributes used in hydration blocks within a single request. Prevents silent data overwrites.
Class Method Summary collapse
- .clear! ⇒ Object
- .register(window_attr, template_path, merge_strategy = nil) ⇒ Object
-
.registry ⇒ Object
Expose registry for testing purposes.
Class Method Details
.clear! ⇒ Object
28 29 30 |
# File 'lib/rhales/hydration_registry.rb', line 28 def clear! Thread.current[:rhales_hydration_registry] = {} end |
.register(window_attr, template_path, merge_strategy = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rhales/hydration_registry.rb', line 8 def register(window_attr, template_path, merge_strategy = nil) validate_inputs(window_attr, template_path) registry = thread_local_registry if registry[window_attr] && merge_strategy.nil? existing = registry[window_attr] raise HydrationCollisionError.new( window_attr, existing[:path], template_path, ) end registry[window_attr] = { path: template_path, merge_strategy: merge_strategy, } end |
.registry ⇒ Object
Expose registry for testing purposes
33 34 35 |
# File 'lib/rhales/hydration_registry.rb', line 33 def registry thread_local_registry end |