Class: ViewComponentReflex::StateAdapter::Session

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

Class Method Summary collapse

Methods inherited from Base

extend_component, extend_reflex

Class Method Details

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



8
9
10
11
12
13
14
# File 'lib/view_component_reflex/state_adapter/session.rb', line 8

def self.set_state(request, controller, key, new_state)
  new_state.each do |k, v|
    state(request, key)[k] = v
  end
  store = request.session.instance_variable_get("@by")
  store.commit_session request, controller.response
end

.state(request, key) ⇒ Object



4
5
6
# File 'lib/view_component_reflex/state_adapter/session.rb', line 4

def self.state(request, key)
  request.session[key] ||= {}
end

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



16
17
18
19
20
21
# File 'lib/view_component_reflex/state_adapter/session.rb', line 16

def self.store_state(request, key, new_state = {})
  request.session[key] = {}
  new_state.each do |k, v|
    request.session[key][k] = v
  end
end

.wrap_write_asyncObject



23
24
25
# File 'lib/view_component_reflex/state_adapter/session.rb', line 23

def self.wrap_write_async
  yield
end