view_component_reflex 3.3.1 → 3.3.3

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: 45cad5ecb337f55a9213805f7f4876f98d6677a7b8f9cb845e40eb427c0016ed
4
- data.tar.gz: 662592a447ce78cac1c0d3b7ceb32a003f66d20bf5a16cd794eab0a476a5288f
3
+ metadata.gz: d0f8913f474b23d0c743eb8a48015bd0f6971f698f51511ff216143648171b17
4
+ data.tar.gz: 4dbfdaf02139d4ac986ff19b314fa1e88d9e7757a2907b26249767c5ed584d13
5
5
  SHA512:
6
- metadata.gz: 0037a5eb9513320b7be49f1e9d3607f50a5560c52240f399e9d965863df0de0e7b1eb038a1650f1d68c117f8e5b906a4085f6dd223206d41076f3961aaad4416
7
- data.tar.gz: 87357055b74a8627f47f1e04cf2d4eaf1c9a7f4d99926579507a5e47af17c8229944975916e3cdff6a6742cf9cae2c9c57123ff8a74ab23d41d19f132eaf8d18
6
+ metadata.gz: 342b1fc02d9cf677e68beca8dedf2efb98d97173363c64e516e311cc3c16ec9f7ddce0ed2698b08c61e9cd13f92217d48b1256b48c33dc9066e492d81587a795
7
+ data.tar.gz: 419f897312a32ce4bfb13f871967fdc4dcc94621c6edc3842aefe8f0cc109e21fe75499fef5c411c7f9880fd611c930f4c61e2ef1918409634bd81dc7c302c13
@@ -252,7 +252,7 @@ module ViewComponentReflex
252
252
  :@virtual_path, :@variant, :@current_template, :@output_buffer, :@key,
253
253
  :@helpers, :@controller, :@request, :@tag_builder, :@state_initialized,
254
254
  :@_content_evaluated, :@_render_in_block, :@__cached_content,
255
- :@original_view_context,
255
+ :@original_view_context, :@compiler,
256
256
  ]
257
257
  end
258
258
 
@@ -276,6 +276,8 @@ module ViewComponentReflex
276
276
  new_state[k] = instance_variable_get(k)
277
277
  end
278
278
 
279
+ p new_state
280
+
279
281
  new_state[:@__cached_content__] = content
280
282
 
281
283
  new_state
@@ -111,21 +111,7 @@ module ViewComponentReflex
111
111
  "[data-controller~=\"#{stimulus_controller}\"][data-key=\"#{element.dataset[:key]}\"]"
112
112
  end
113
113
 
114
- # SR's delegate_call_to_reflex in channel.rb
115
- # uses method to gather the method parameters, but since we're abusing
116
- # method_missing here, that'll always fail
117
- def method(name)
118
- component.adapter.extend_reflex(self)
119
- component.method(name.to_sym)
120
- end
121
-
122
- def respond_to_missing?(name, _ = false)
123
- !!name.to_proc
124
- end
125
-
126
- def method_missing(name, *args, &blk)
127
- super unless respond_to_missing?(name)
128
-
114
+ def delegate_call_to_reflex(name, *args, &blk)
129
115
  state.each do |k, v|
130
116
  component.instance_variable_set(k, v)
131
117
  end
@@ -31,7 +31,23 @@ module ViewComponentReflex
31
31
  end
32
32
 
33
33
  def reflex_instance
34
- @reflex_instance ||= Class.new(@component.reflex_base_class)
34
+ @reflex_instance ||= build_reflex_instance
35
+ end
36
+
37
+ ##
38
+ # Beyond just creating the <Component>Reflex class, we need to define all the component methods on the reflex
39
+ # class.
40
+ # This replaces the old method_missing implementation, and passes more strict validation of recent SR versions
41
+ def build_reflex_instance
42
+ reflex_methods = @component.instance_methods - @component.superclass.instance_methods - [:call, :"_call_#{@component.name.underscore}"]
43
+
44
+ Class.new(@component.reflex_base_class).tap do |klass|
45
+ reflex_methods.each do |m|
46
+ klass.define_method(m) do |*args, &blk|
47
+ delegate_call_to_reflex(method_name, *args, &blk)
48
+ end
49
+ end
50
+ end
35
51
  end
36
52
 
37
53
  def reflex_from_nested_component
@@ -1,3 +1,3 @@
1
1
  module ViewComponentReflex
2
- VERSION = '3.3.1'
2
+ VERSION = '3.3.3'
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: 3.3.1
4
+ version: 3.3.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: 2023-07-24 00:00:00.000000000 Z
11
+ date: 2024-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  requirements: []
119
- rubygems_version: 3.4.10
119
+ rubygems_version: 3.5.6
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: Allow stimulus reflexes in a view component