view_component_reflex 3.3.10 → 3.3.12

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: b0da7312422e650e83bed844e15b88df77007686ab1ab70c8045d9ee55ce323d
4
- data.tar.gz: 4e2693185587394fc00846208d2937ed17aed3a9a81b9c3d63096b6605a16ec6
3
+ metadata.gz: 0b70948aa0b5a3f2180be72f0649398dc22096189f38d26a7ffbf18d30944999
4
+ data.tar.gz: d7f0080cfad13e801d30c79b3886d686d98ad025958c5454374c2541d28e5236
5
5
  SHA512:
6
- metadata.gz: d68f2892791824604bd9e0cf82a2b701f28fb59eb869d44dd1638b252bc9adcc11499c9d71ac38a497407bf1c0a86edba075f7832566000ace03f5ad4cd000e6
7
- data.tar.gz: ffb3976d8bf8d5c9b77539eed78b06b5b9014b75827f4b79b5305f4d332ef7b653e0257e6e611507a1dd7aaa53109f434747d97cfb3e7856da5948efd21dd293
6
+ metadata.gz: 85cf2658d9f2d73b2e9994497ff31a06009d91fb65bdd3327497d108026332bda876054e5485ef36f1075aa0ebe8d1f483f77cb05d7552f1bcb0b57faa9f3d0d
7
+ data.tar.gz: ba74b77b06516184b60c4766bb0e9a352b34dc824fab66cb2be6d479bd94267c29573972dc0fb654e05132eb399a468ce05fb2743ed8441702d237386226c124
@@ -34,19 +34,49 @@ module ViewComponentReflex
34
34
  @reflex_instance ||= build_reflex_instance
35
35
  end
36
36
 
37
+ def reflex_methods
38
+ arr = []
39
+ current_class = @component
40
+ loop do
41
+ arr += current_class.instance_methods
42
+ current_class = current_class.superclass
43
+ break if current_class == ViewComponentReflex::Component || current_class.nil?
44
+ end
45
+ arr -= ViewComponentReflex::Component.instance_methods
46
+ arr -= [:call, :"_call_#{@component.name.underscore}"]
47
+ arr
48
+ end
49
+
37
50
  ##
38
51
  # Beyond just creating the <Component>Reflex class, we need to define all the component methods on the reflex
39
52
  # class.
40
53
  # This replaces the old method_missing implementation, and passes more strict validation of recent SR versions
41
54
  def build_reflex_instance
42
- reflex_methods = @component.instance_methods - @component.superclass.instance_methods - [:call, :"_call_#{@component.name.underscore}"]
43
-
55
+ component_allocate = @component.allocate
44
56
  Class.new(@component.reflex_base_class).tap do |klass|
57
+ klass.instance_variable_set(:@__method_parameters, {})
58
+
45
59
  reflex_methods.each do |m|
60
+ klass.instance_variable_get(:@__method_parameters)[m.to_s] = component_allocate.method(m).parameters
46
61
  klass.define_method(m) do |*args, &blk|
47
62
  delegate_call_to_reflex(m, *args, &blk)
48
63
  end
49
64
  end
65
+
66
+ # SR does validation of incoming arguments against method definitions
67
+ # so we need to fake our method definitions call here
68
+ klass.define_method(:method) do |name|
69
+ method = super(name)
70
+ params = self.class.instance_variable_get(:@__method_parameters)
71
+
72
+ if params && params[name]
73
+ method.define_singleton_method(:parameters) do
74
+ params[name]
75
+ end
76
+ end
77
+
78
+ method
79
+ end
50
80
  end
51
81
  end
52
82
 
@@ -1,3 +1,3 @@
1
1
  module ViewComponentReflex
2
- VERSION = '3.3.10'
2
+ VERSION = '3.3.12'
3
3
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component_reflex
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.10
4
+ version: 3.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua LeBlanc
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-05-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rails
@@ -101,7 +100,6 @@ licenses:
101
100
  - MIT
102
101
  metadata:
103
102
  allowed_push_host: https://rubygems.org
104
- post_install_message:
105
103
  rdoc_options: []
106
104
  require_paths:
107
105
  - lib
@@ -116,8 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
114
  - !ruby/object:Gem::Version
117
115
  version: '0'
118
116
  requirements: []
119
- rubygems_version: 3.5.16
120
- signing_key:
117
+ rubygems_version: 3.6.9
121
118
  specification_version: 4
122
119
  summary: Allow stimulus reflexes in a view component
123
120
  test_files: []