Class: ViewComponentReflex::StateAdapter::Memory
- Defined in:
- lib/view_component_reflex/state_adapter/memory.rb
Class Method Summary collapse
- .set_state(request, _, key, new_state) ⇒ Object
- .state(request, key) ⇒ Object
- .store_state(request, key, new_state = {}) ⇒ Object
- .wrap_write_async ⇒ Object
Methods inherited from Base
extend_component, extend_reflex
Class Method Details
.set_state(request, _, key, new_state) ⇒ Object
12 13 14 15 16 |
# File 'lib/view_component_reflex/state_adapter/memory.rb', line 12 def self.set_state(request, _, key, new_state) new_state.each do |k, v| state(request, key)[k] = v end end |
.state(request, key) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/view_component_reflex/state_adapter/memory.rb', line 5 def self.state(request, key) id = extract_id(request) VIEW_COMPONENT_REFLEX_MEMORY_STATE[id] ||= {} VIEW_COMPONENT_REFLEX_MEMORY_STATE[id][key] ||= {} end |
.store_state(request, key, new_state = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/view_component_reflex/state_adapter/memory.rb', line 18 def self.store_state(request, key, new_state = {}) id = extract_id(request) VIEW_COMPONENT_REFLEX_MEMORY_STATE[id] ||= {} VIEW_COMPONENT_REFLEX_MEMORY_STATE[id][key] = {} new_state.each do |k, v| VIEW_COMPONENT_REFLEX_MEMORY_STATE[id][key][k] = v end end |
.wrap_write_async ⇒ Object
28 29 30 |
# File 'lib/view_component_reflex/state_adapter/memory.rb', line 28 def self.wrap_write_async yield end |