view_component_reflex 3.3.9 → 3.3.11

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: 9d647f83bbea99b1c83d5b6de6f99a72716db151d8ca0e463d04100badf64c2a
4
- data.tar.gz: 1c6606eb1e577690623f528035398dffa6c3023d13c9eb01a6643dcfa49364b0
3
+ metadata.gz: 66a0225dccbc3322e26185994160ecd2dad4c589718241be92ae9753f98f90f1
4
+ data.tar.gz: 7e9eecd26517012019e428286f0879723890d965d52eedd20805d537c59894fe
5
5
  SHA512:
6
- metadata.gz: a5c5fe3a05f533be3c1558f23714d0bfc572c2456dab33ed097d76a63c5d5d461e8fb9dc51d2c8d1aa645492a5eac3ddc8dfde1d90c330568af12d1800c20cda
7
- data.tar.gz: 9cf0c59a718c2a9e1b92b122dac1b1149a4c36cc1d3eb584fd321cdf46d35cdc7ff448f6f43a5164115729eec907d19ba9aa96180f39b3ebdcd92352bf1c197a
6
+ metadata.gz: be07fb9df8268c0511297c9b0b1c3e2be9dde2c4f9bcd80d1a9ff222c0719215a77d8f1965ce2a0f00b6e0fc7a8d9ae24d5dbc9f0872a17158e8982e28698998
7
+ data.tar.gz: 155b0d69d9dfabd95131c1335ab39e1998400fc9debc32b4856bf73a8cff9dca6e68c83a7c012dd32719079d277076a2bde769c1b5ffc3b86ee31e86c277447d
@@ -186,13 +186,14 @@ module ViewComponentReflex
186
186
  def initialize_key
187
187
  # we want the erb file that renders the component. `caller` gives the file name,
188
188
  # and line number, which should be unique. We hash it to make it a nice number
189
- erb_file = caller.select { |p| p.match? /.\.html\.(haml|erb|slim)/ }[1]
190
- key = if erb_file
191
- erb_file.split(":in")[0]
192
-
193
- else
194
- ""
195
- end
189
+ key = caller.select { |p| p.match? /.\.html\.(haml|erb|slim)/ }.map do |erb_file|
190
+ if erb_file
191
+ erb_file.split(":in")[0]
192
+ else
193
+ ""
194
+ end
195
+ end.join("+")
196
+
196
197
  key += collection_key.to_s if collection_key
197
198
  @key = Digest::SHA2.hexdigest(key)
198
199
  end
@@ -40,13 +40,31 @@ module ViewComponentReflex
40
40
  # This replaces the old method_missing implementation, and passes more strict validation of recent SR versions
41
41
  def build_reflex_instance
42
42
  reflex_methods = @component.instance_methods - @component.superclass.instance_methods - [:call, :"_call_#{@component.name.underscore}"]
43
-
43
+ component_allocate = @component.allocate
44
44
  Class.new(@component.reflex_base_class).tap do |klass|
45
+ klass.instance_variable_set(:@__method_parameters, {})
46
+
45
47
  reflex_methods.each do |m|
48
+ klass.instance_variable_get(:@__method_parameters)[m.to_s] = component_allocate.method(m).parameters
46
49
  klass.define_method(m) do |*args, &blk|
47
50
  delegate_call_to_reflex(m, *args, &blk)
48
51
  end
49
52
  end
53
+
54
+ # SR does validation of incoming arguments against method definitions
55
+ # so we need to fake our method definitions call here
56
+ klass.define_method(:method) do |name|
57
+ method = super(name)
58
+ params = self.class.instance_variable_get(:@__method_parameters)
59
+
60
+ if params && params[name]
61
+ method.define_singleton_method(:parameters) do
62
+ params[name]
63
+ end
64
+ end
65
+
66
+ method
67
+ end
50
68
  end
51
69
  end
52
70
 
@@ -1,3 +1,3 @@
1
1
  module ViewComponentReflex
2
- VERSION = '3.3.9'
2
+ VERSION = '3.3.11'
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.9
4
+ version: 3.3.11
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-26 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: []