view_component_reflex 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25f3eb9ce0b0a130b3448c9aa350636e86f4497c9274a1a4ba7edfb564d11a16
|
4
|
+
data.tar.gz: 809b06a816a92e8ba1e3ce0198c55c6f3d812a0ad3c4b447300c56e4733102b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3c0cf57dda891149ccd671d02fbc967aaa83277f789a1cd0c7c75192fa4a83e3e593177ef49f904cbc9cc8bb241b9506527bfafee0b90b049252b1822a4cb68
|
7
|
+
data.tar.gz: 94c5b424ae03b1f35f797ddebf0d6f24bf78b05960140c415cce86d4c2bf645ce4eef7445d7049ef57ab0d2f26925bac251b0a202199840f23f4f0adee22fc17
|
data/README.md
CHANGED
@@ -89,23 +89,6 @@ class YourAdapter
|
|
89
89
|
# new_state - a hash containing the component state
|
90
90
|
def self.store_state(request, key, new_state = {})
|
91
91
|
# store the state
|
92
|
-
# this will be called twice, once with key, once with key_initial
|
93
|
-
# key_initial contains the initial, unmodified state.
|
94
|
-
# it should be used in reconcile_state to decide whether or not
|
95
|
-
# to re-initialize the state
|
96
|
-
end
|
97
|
-
|
98
|
-
##
|
99
|
-
# request - a rails request object
|
100
|
-
# key - a unique string that identifies the component instance
|
101
|
-
# new_state - a hash containing the component state
|
102
|
-
def self.reconcile_state(request, key, new_state)
|
103
|
-
# The passed state should always match the initial state of the component
|
104
|
-
# if it doesn't, we need to reset the state to the passed value.
|
105
|
-
#
|
106
|
-
# This handles cases where your initialize_state param computes some value that changes
|
107
|
-
# initialize_state({ transaction: @customer.transactions.first })
|
108
|
-
# if you delete the first transaction, that ^ is no longer valid. We need to update the state.
|
109
92
|
end
|
110
93
|
end
|
111
94
|
```
|
@@ -73,9 +73,6 @@ module ViewComponentReflex
|
|
73
73
|
# initialize session state
|
74
74
|
if !stimulus_reflex? || session[@key].nil?
|
75
75
|
ViewComponentReflex::Engine.state_adapter.store_state(request, @key, @state)
|
76
|
-
ViewComponentReflex::Engine.state_adapter.store_state(request, "#{@key}_initial", @state)
|
77
|
-
else
|
78
|
-
# ViewComponentReflex::Engine.state_adapter.reconcile_state(request, @key, @state)
|
79
76
|
end
|
80
77
|
@key
|
81
78
|
end
|
@@ -19,20 +19,6 @@ module ViewComponentReflex
|
|
19
19
|
request.session[key][k] = v
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
23
|
-
# The passed state should always match the initial state of the component
|
24
|
-
# if it doesn't, we need to reset the state to the passed value.
|
25
|
-
#
|
26
|
-
# This handles cases where your initialize_state param computes some value that changes
|
27
|
-
# initialize_state({ transaction: @customer.transactions.first })
|
28
|
-
# if you delete the first transaction, that ^ is no longer valid. We need to update the state.
|
29
|
-
def self.reconcile_state(request, key, new_state)
|
30
|
-
request.session["#{key}_initial"].each do |k, v|
|
31
|
-
if new_state[k] != v
|
32
|
-
request.session[key][k] = new_state[k]
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
22
|
end
|
37
23
|
end
|
38
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: view_component_reflex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua LeBlanc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|