chewy 8.4.0 → 8.4.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: bbef8e814a251ebcf189865c37c82476a8e3397983c4ede20694df87a7a61bd9
4
- data.tar.gz: e673c1ab4ae490dd3ae716bcb3e617a0661f87c3f43143f59237a46228777375
3
+ metadata.gz: c7ffb0b83cbd361f40168edad592083762af5035dc02ca60f205f16c6224a9a6
4
+ data.tar.gz: ca56cddc2b59646fbaa9188c707c1d9f23d9dabf2166e1a1ff168d83adf6e6ef
5
5
  SHA512:
6
- metadata.gz: '04927525ee47f4f5591ed3f826d2477a87f267be465b739070c82cf1c54d558fe77d56bc88868d35be5fa6c27c8a0302ac31b6fd1f7c79c18b0759eb3e14eabf'
7
- data.tar.gz: 62c30c3643ed78e661409929e5a075f02cbac789978f84d0a89531e00ab90764782dc085a7a44243b53b5613466794baa4b881eb22c55abdbde7b46bbb583966
6
+ metadata.gz: 91751c0575275edd79e08a945fed07b775a6cd0cd216c3fcba95fbab4085b22dd476d23485c63ee93d740b3f2b8e08bc742789e6f60313fcc49d43013bd48ebe
7
+ data.tar.gz: 4de8630df6346a7eccbbd14ca0cc2b5d84d636e314c58840cae605433a570e6a9b6c07bf8d2f27b695808efcdc491b41006fd4a18038412ee485fe36669711bb
data/CHANGELOG.md CHANGED
@@ -8,6 +8,16 @@
8
8
 
9
9
  ### Changes
10
10
 
11
+ ## 8.4.1 (2026-06-19)
12
+
13
+ ### New Features
14
+
15
+ ### Bug Fixes
16
+
17
+ * [#1043](https://github.com/toptal/chewy/pull/1043)Fixed `field ..., value: proc(&:method)` (and other splat-declaring procs) raising `ArgumentError: wrong number of arguments` during import. The compiled compose path introduced in 8.4.0 forwarded `crutches`/`context` as extra positional arguments to splat procs; `Symbol#to_proc` then passed them on to the method. Splat procs are now called with the object alone, matching the plain compose path. ([@AlfonsoUceda][])
18
+
19
+ ### Changes
20
+
11
21
  ## 8.4.0 (2026-06-17)
12
22
 
13
23
  ### New Features
@@ -187,17 +187,24 @@ module Chewy
187
187
  idx = @procs.size
188
188
  @procs << v
189
189
  procs_ref = "compiled_procs[#{idx}]"
190
- param_count = positional_param_count(v)
191
- case v.arity
192
- when 0
190
+ if v.arity.zero?
193
191
  "#{obj_var}.instance_exec(&#{procs_ref})"
192
+ elsif v.parameters.any? { |type, _| type == :rest }
193
+ # Procs that declare a splat — Symbol#to_proc (`proc(&:method)`,
194
+ # parameters `[[:req], [:rest]]`) and `->(*args)` — must NOT
195
+ # receive crutches/context as extra positional args: a symbol
196
+ # proc would forward them to the method (`obj.method(crutches,
197
+ # context)` => "wrong number of arguments"). Mirror the plain
198
+ # Base#value_by_proc negative-arity branch (`value.call(*object)`)
199
+ # so the compiled and fallback paths behave identically.
200
+ "#{procs_ref}.call(*#{obj_var})"
194
201
  else
195
202
  # Pass only as many of (object, crutches, context) as the
196
203
  # proc actually declares. This keeps lambdas with optional
197
204
  # args (negative arity like `->(o, c=nil)`) from being
198
205
  # called with too many arguments. Anything beyond context
199
206
  # truncates to all three.
200
- args = [obj_var, 'crutches', 'context'].first(param_count)
207
+ args = [obj_var, 'crutches', 'context'].first(positional_param_count(v))
201
208
  "#{procs_ref}.call(#{args.join(', ')})"
202
209
  end
203
210
  else
@@ -212,14 +219,13 @@ module Chewy
212
219
  end
213
220
  end
214
221
 
215
- # Number of positional parameters declared by `proc`, counting
216
- # required + optional. Splats and keyword args contribute one
217
- # bucket each so the caller still passes all three context args.
222
+ # Number of (object, crutches, context) args to pass to a splat-free
223
+ # proc: its required + optional positional parameters, capped at the
224
+ # three available. Splat procs are handled by the caller and never
225
+ # reach here.
218
226
  def positional_param_count(proc)
219
- params = proc.parameters
220
- required = params.count { |type, _| %i[req opt].include?(type) }
221
- has_splat = params.any? { |type, _| type == :rest }
222
- has_splat ? 3 : [required, 3].min
227
+ required = proc.parameters.count { |type, _| %i[req opt].include?(type) }
228
+ [required, 3].min
223
229
  end
224
230
 
225
231
  def safe_identifier?(name)
data/lib/chewy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Chewy
2
- VERSION = '8.4.0'.freeze
2
+ VERSION = '8.4.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chewy
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.4.0
4
+ version: 8.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toptal, LLC