view_component_reflex 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 163bc65c20bb1ac85bb9e15ee2ce4fbf7039a9d90cbe7c4cb1591d03699edc71
|
4
|
+
data.tar.gz: fb80faac53511b705e0170da3cfae4c7c82c1a59c6bf773e8b86eea30463b9f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9936a4885f9b8e625eca11ac78af316f475764688a5fd2aca9f098aabd802c5e578bdca12266b7176c52c3ff6302dcf7c703e1dd902194bc2dd8c20a1071ab14
|
7
|
+
data.tar.gz: e5fca59e3e33091ee7b53df0d0cf40007b476835f141cd3f717d7b86e14fde3cec8ffce960a4f23b7ffe5f12a48d10a6917843a9e33c67d911b76485187796c7
|
@@ -100,6 +100,7 @@ module ViewComponentReflex
|
|
100
100
|
|
101
101
|
def component_controller(opts = {}, &blk)
|
102
102
|
self.class.init_stimulus_reflex
|
103
|
+
init_key
|
103
104
|
opts[:data] = {
|
104
105
|
controller: self.class.stimulus_controller,
|
105
106
|
key: key,
|
@@ -108,23 +109,23 @@ module ViewComponentReflex
|
|
108
109
|
content_tag :div, capture(&blk), opts
|
109
110
|
end
|
110
111
|
|
111
|
-
def collection_key
|
112
|
-
nil
|
113
|
-
end
|
114
|
-
|
115
112
|
# key is required if you're using state
|
116
113
|
# We can't initialize the session state in the initial method
|
117
114
|
# because it doesn't have a view_context yet
|
118
115
|
# This is the next best place to do it
|
119
|
-
def
|
116
|
+
def init_key
|
120
117
|
# we want the erb file that renders the component. `caller` gives the file name,
|
121
118
|
# and line number, which should be unique. We hash it to make it a nice number
|
122
119
|
key = caller.select { |p| p.include? ".html.erb" }[1]&.hash.to_s
|
123
120
|
key += collection_key.to_s if collection_key
|
124
|
-
|
125
|
-
|
126
|
-
|
121
|
+
@key = key
|
122
|
+
end
|
123
|
+
|
124
|
+
def collection_key
|
125
|
+
nil
|
126
|
+
end
|
127
127
|
|
128
|
+
def key
|
128
129
|
# initialize session state
|
129
130
|
if !stimulus_reflex? || session[@key].nil?
|
130
131
|
new_state = {}
|
@@ -133,7 +134,7 @@ module ViewComponentReflex
|
|
133
134
|
blacklist = [
|
134
135
|
:@view_context, :@lookup_context, :@view_renderer, :@view_flow,
|
135
136
|
:@virtual_path, :@variant, :@current_template, :@output_buffer, :@key,
|
136
|
-
:@helpers, :@controller, :@request
|
137
|
+
:@helpers, :@controller, :@request, :@content
|
137
138
|
]
|
138
139
|
instance_variables.reject { |k| blacklist.include?(k) }.each do |k|
|
139
140
|
new_state[k] = instance_variable_get(k)
|
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: 1.1.
|
4
|
+
version: 1.1.1
|
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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|