view_component_reflex 1.1.0 → 1.1.1

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: 42797141d9ed8ecfb013f8f68c9e073b9ee6db4fe4eb04f1c7484babbd2c4e06
4
- data.tar.gz: 9dfb73b083e7e1ac3417a676f37962c1861435310e0f04934d16cea5824f6eb3
3
+ metadata.gz: 163bc65c20bb1ac85bb9e15ee2ce4fbf7039a9d90cbe7c4cb1591d03699edc71
4
+ data.tar.gz: fb80faac53511b705e0170da3cfae4c7c82c1a59c6bf773e8b86eea30463b9f5
5
5
  SHA512:
6
- metadata.gz: 4505fedd6b66cf2e5b31fe3cdeb8ec3b337a0c6b8de79082926d637c39dd74770b562280ae6f61bc79f434b2184e993c706dcd7fac088d436b185e56228f7d28
7
- data.tar.gz: ed2b650393469281ecd997a7589f6e9999a1aeda25e624193c54c61c1d7e7b78b012718945c409c5db8db86588a7ea64e1be547a4d351e92b377329eef1d7e18
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 key
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
- if @key.nil? || @key.empty?
125
- @key = key
126
- end
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)
@@ -1,3 +1,3 @@
1
1
  module ViewComponentReflex
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  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: 1.1.0
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-19 00:00:00.000000000 Z
11
+ date: 2020-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails