sequel-packer 1.0.1 → 1.0.2

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: 8782014d5d4fd8a6da590674ebc1d8d7a248f13ab80a1c571a0036f5a158af4f
4
- data.tar.gz: d58397494def47b14aba23ce8f3dd2006936116e1273016f5bafb8e22c20809a
3
+ metadata.gz: f98891d415535fdd69c20f666ca19b50636de2fac2b90fdbbe345a2a1748f9f5
4
+ data.tar.gz: 001c044055db9aa83e01c7682fd8192fd4ec9d3e33fce87641aac9dada5d3956
5
5
  SHA512:
6
- metadata.gz: a30ae3faee56c47a4da2efcddb0a09cb5cbf892451968d010fddd2c3b937b59caadeb3128c78c4ca94d8cfaf0d2741755459fb1729c4f6fbb9b97f2787289201
7
- data.tar.gz: 109e270732bec0bb7311f5d5f5a7e5f9c6f5f91e4a685bbdec5e20f28a38ef92093fd64d56067e6e64a3a718c2076df700b82e401f2004898aee846dc6cd879b
6
+ metadata.gz: 9d087766c42af1d13853632acd94df1cd14c93e1a82df9e4def52fc610428292d02ec698cebf8eb33f6a09a3085c37c1d9a7461b22f92d21231c4a854ffec275
7
+ data.tar.gz: 00d2f9e8ac685346b2bc615e394b9fdb104a039427d3160f1e5ffb6f86ee18a1afc02d903130ed6fad6b8120450f3f8876ac82c48f9fdb16998fe08858fb10ef
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ### 1.0.2 (2023-05-11)
2
+
3
+ * Update validation of the arity of the blocks passed to `field` to account
4
+ for the change in the arity of procs created by `&:sym` in Ruby 3. The updated
5
+ validation should support both Ruby 2 and Ruby 3 versions.
6
+
1
7
  ### 1.0.1 (2021-08-02)
2
8
 
3
9
  * Update internal method call to remove "Using the last argument as
@@ -1,5 +1,13 @@
1
1
  require 'sequel'
2
2
 
3
+ # Before Ruby 3, the arity of the proc created by `&:sym` was -1.
4
+ # In Ruby 3, this was changed to -2 to reflect that the proc requires
5
+ # the receiver the method should be called on.
6
+ #
7
+ # See: https://bugs.ruby-lang.org/issues/16260
8
+ # And: https://stackoverflow.com/a/70100210
9
+ SYM_TO_PROC_ARITY = RUBY_VERSION < '3' ? -1 : -2
10
+
3
11
  module Sequel
4
12
  class Packer
5
13
  module Validation
@@ -42,8 +50,13 @@ module Sequel
42
50
 
43
51
  arity = block.arity
44
52
 
45
- # When using Symbol.to_proc (field(:foo, &:calculate_foo)), the block has arity -1.
46
- if field_name && arity != 1 && arity != -1
53
+ # If passing a literal block, as in `field(:foo) {|model| ... }`, the block
54
+ # will have arity 1 (1 required argument).
55
+ #
56
+ # When using Symbol.to_proc via `field(:foo, &:calculate_foo)`, the arity of
57
+ # the block depends which version Ruby is running. Before Ruby 3 the arity of
58
+ # the proc returned by `&:sym` had arity -1, but was updated to be -2 in Ruby 3.
59
+ if field_name && arity != 1 && arity != SYM_TO_PROC_ARITY
47
60
  raise(
48
61
  FieldArgumentError,
49
62
  "The block used to define :#{field_name} must accept exactly " +
@@ -1,5 +1,5 @@
1
1
  module Sequel
2
2
  class Packer
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel-packer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Julius Martinez
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-02 00:00:00.000000000 Z
11
+ date: 2023-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -140,7 +140,7 @@ metadata:
140
140
  homepage_uri: https://github.com/PaulJuliusMartinez/sequel-packer
141
141
  source_code_uri: https://github.com/PaulJuliusMartinez/sequel-packer
142
142
  changelog_uri: https://github.com/PaulJuliusMartinez/sequel-packer/blob/master/CHANGELOG.md
143
- post_install_message:
143
+ post_install_message:
144
144
  rdoc_options: []
145
145
  require_paths:
146
146
  - lib
@@ -155,8 +155,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
155
  - !ruby/object:Gem::Version
156
156
  version: '0'
157
157
  requirements: []
158
- rubygems_version: 3.1.2
159
- signing_key:
158
+ rubygems_version: 3.4.1
159
+ signing_key:
160
160
  specification_version: 4
161
161
  summary: A serialization library for use with the Sequel ORM.
162
162
  test_files: []