sequel-packer 1.0.0 → 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: b3668368d8bc70c9c48aed2d48180c46caf75749eec556e4625e134534f65760
4
- data.tar.gz: bcd3643f407dd675b80b5b76719ee6906b0892d8b437b0415712c81e271bdba1
3
+ metadata.gz: f98891d415535fdd69c20f666ca19b50636de2fac2b90fdbbe345a2a1748f9f5
4
+ data.tar.gz: 001c044055db9aa83e01c7682fd8192fd4ec9d3e33fce87641aac9dada5d3956
5
5
  SHA512:
6
- metadata.gz: 979da0d59439adbb1065cdd0a07977b7a9192842d2df8cf753ccfac306b26b92361a340536d4125c31901f7ad2d064eb4dc563ba246c8f667c7b7af2ee9937e1
7
- data.tar.gz: 8e8ed34ddc5e6059253454772fe7f089e9bb662eebd4ec1d44c7d2d0699cd6cc9800d347fa1d9a82aa3dfd16606df3e7a062e6a62ec4f08e7aed72f4c6c4aab0
6
+ metadata.gz: 9d087766c42af1d13853632acd94df1cd14c93e1a82df9e4def52fc610428292d02ec698cebf8eb33f6a09a3085c37c1d9a7461b22f92d21231c4a854ffec275
7
+ data.tar.gz: 00d2f9e8ac685346b2bc615e394b9fdb104a039427d3160f1e5ffb6f86ee18a1afc02d903130ed6fad6b8120450f3f8876ac82c48f9fdb16998fe08858fb10ef
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
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
+
7
+ ### 1.0.1 (2021-08-02)
8
+
9
+ * Update internal method call to remove "Using the last argument as
10
+ keyword parameters is deprecated" warning.
11
+
1
12
  ### 1.0.0 (2020-05-18)
2
13
 
3
14
  * Version 1.0.0 release! No changes since 0.5.0 except some small changes to the
@@ -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.0"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
data/lib/sequel/packer.rb CHANGED
@@ -222,7 +222,7 @@ module Sequel
222
222
 
223
223
  # Create all the subpackers, and merge in their eager hashes.
224
224
  @instance_packers.each do |association, (subpacker, traits)|
225
- association_packer = subpacker.new(*traits, @context)
225
+ association_packer = subpacker.new(*traits, **@context)
226
226
 
227
227
  @subpackers[association] = association_packer
228
228
 
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.0
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: 2020-05-19 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: []