Class: ViewComponentReflex::StateAdapter::Dom

Inherits:
Base
  • Object
show all
Defined in:
lib/view_component_reflex/state_adapter/dom.rb

Class Method Summary collapse

Class Method Details

.extend_component(component) ⇒ Object



43
44
45
# File 'lib/view_component_reflex/state_adapter/dom.rb', line 43

def self.extend_component(component)
  component.extend ViewComponentReflex::Dom::Component
end

.extend_reflex(reflex) ⇒ Object



47
48
49
# File 'lib/view_component_reflex/state_adapter/dom.rb', line 47

def self.extend_reflex(reflex)
  reflex.extend ViewComponentReflex::Dom::Reflex
end

.set_state(request, _, key, new_state) ⇒ Object



25
26
27
28
29
# File 'lib/view_component_reflex/state_adapter/dom.rb', line 25

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



17
18
19
20
21
22
23
# File 'lib/view_component_reflex/state_adapter/dom.rb', line 17

def self.state(request, key)
  id = extract_id(request)

  CurrentState.state ||= {}
  CurrentState.state[id] ||= {}
  CurrentState.state[id][key] ||= {}
end

.store_state(request, key, new_state = {}) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/view_component_reflex/state_adapter/dom.rb', line 31

def self.store_state(request, key, new_state = {})
  id = extract_id(request)

  CurrentState.state ||= {}
  CurrentState.state[id] ||= {}
  CurrentState.state[id][key] = {}

  new_state.each do |k, v|
    CurrentState.state[id][key][k] = v
  end
end

.wrap_write_asyncObject



51
52
53
# File 'lib/view_component_reflex/state_adapter/dom.rb', line 51

def self.wrap_write_async
  yield
end