dry-struct 1.8.0 → 1.8.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: ca7dd75ba219a6860a4532f8ede515b598b70e32ef8f0e07d4f42d99ea429111
4
- data.tar.gz: 37c2870ddde97c4da85845f2f5118c13443eb9dcec600588542bab6ef7a8960e
3
+ metadata.gz: b3949661d29cee88a8d29876846e0f6dd4e092f2f65a43307cfaa38814bf8f8b
4
+ data.tar.gz: ec23916ce98b47fecd001b958620e190fed5688a929b002f4cc048620a3df999
5
5
  SHA512:
6
- metadata.gz: 9848e0d45c5031418374744045f6866d5a991398376f17524d8326b41abd22b9109f0476d641a680cd5f5acab76d5493262d40cae335dc0ee7864f7958080992
7
- data.tar.gz: 974e9069e93e5a16d57fe5f9744ba24339fa0a30d26487d5f2ade5a0a7ae07c79d995160f380e45838b83b8e4851e52c4705c7d7cea9634ab4404a8816ebf6da
6
+ metadata.gz: 5458cb033a707cce2d4058b71ed81ec791d3ecfe98b4c8f9520b9297453c31df7fd2f658b1083230288761279053db0b2fd5db3481f8fa450ff1a2d8a29e6783
7
+ data.tar.gz: 449f59b1cb3954d815c8ba7191e148e05ac8d594cc89f56e7673bcca9922e7ab5cdc447e6a591a3154993ea81298cf0ec3d9c7a330c5bd1979395f96118d97a1
data/CHANGELOG.md CHANGED
@@ -1,7 +1,35 @@
1
- <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
1
+ # Changelog
2
2
 
3
- ## 1.8.0 2025-03-09
3
+ All notable changes to this project will be documented in this file.
4
4
 
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Break Versioning](https://www.taoensso.com/break-versioning).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+
12
+ ### Changed
13
+
14
+ ### Deprecated
15
+
16
+ ### Removed
17
+
18
+ ### Fixed
19
+
20
+ ### Security
21
+
22
+ [Unreleased]: https://github.com/dry-rb/dry-struct/compare/v1.8.1...main
23
+
24
+ ## [1.8.1] - 2026-03-03
25
+
26
+ ### Changed
27
+
28
+ - Performance improvements for building a hash from `Dry::Struct` when it contains nested structs. (@katafrakt in #202, identified by @rpeng in #200)
29
+
30
+ [1.8.1]: https://github.com/dry-rb/dry-struct/compare/v1.8.0...v1.8.1
31
+
32
+ ## [1.8.0] - 2025-03-09
5
33
 
6
34
  ### Added
7
35
 
@@ -46,21 +74,17 @@
46
74
  }>
47
75
  ```
48
76
 
77
+ [1.8.0]: https://github.com/dry-rb/dry-struct/compare/v1.7.1...v1.8.0
49
78
 
50
- [Compare v1.7.1...v1.8.0](https://github.com/dry-rb/dry-struct/compare/v1.7.1...v1.8.0)
51
-
52
- ## 1.7.1 2025-01-31
53
-
79
+ ## [1.7.1] - 2025-01-31
54
80
 
55
81
  ### Fixed
56
82
 
57
83
  - Syntax errors on 3.3.0 (@flash-gordon, see https://github.com/dry-rb/dry-types/issues/478)
58
84
 
85
+ [1.7.1]: https://github.com/dry-rb/dry-struct/compare/v1.7.0...v1.7.1
59
86
 
60
- [Compare v1.7.0...v1.7.1](https://github.com/dry-rb/dry-struct/compare/v1.7.0...v1.7.1)
61
-
62
- ## 1.7.0 2025-01-06
63
-
87
+ ## [1.7.0] - 2025-01-06
64
88
 
65
89
  ### Fixed
66
90
 
@@ -74,48 +98,41 @@
74
98
  - `Dry::Struct::Error` is now a subclass of `Dry::Types::CoercionError` (in #193) (@flash-gordon)
75
99
  - `Dry::Struct#[]` now returns `nil` if an optional attribute is not set. This is consistent with calling accessor methods for optional attributes. (issue #171 via #194) (@ivleonov + @flash-gordon)
76
100
 
77
- [Compare v1.6.0...v1.7.0](https://github.com/dry-rb/dry-struct/compare/v1.6.0...v1.7.0)
78
-
79
- ## 1.6.0 2022-11-04
101
+ [1.7.0]: https://github.com/dry-rb/dry-struct/compare/v1.6.0...v1.7.0
80
102
 
103
+ ## [1.6.0] - 2022-11-04
81
104
 
82
105
  ### Changed
83
106
 
84
107
  - This version uses dry-core 1.0 (@flash-gordon + @solnic)
85
108
 
86
- [Compare v1.5.2...v1.6.0](https://github.com/dry-rb/dry-struct/compare/v1.5.2...v1.6.0)
87
-
88
- ## 1.5.2 2022-10-19
109
+ [1.6.0]: https://github.com/dry-rb/dry-struct/compare/v1.5.2...v1.6.0
89
110
 
111
+ ## [1.5.2] - 2022-10-19
90
112
 
91
113
  ### Fixed
92
114
 
93
115
  - Coercion failures keep the original error instead of just having a string (@flash-gordon + @newx)
94
116
 
117
+ [1.5.2]: https://github.com/dry-rb/dry-struct/compare/v1.5.1...v1.5.2
95
118
 
96
- [Compare v1.5.1...v1.5.2](https://github.com/dry-rb/dry-struct/compare/v1.5.1...v1.5.2)
97
-
98
- ## 1.5.1 2022-10-17
99
-
119
+ ## [1.5.1] - 2022-10-17
100
120
 
101
121
  ### Fixed
102
122
 
103
123
  - Fixed issues with auto-loading `Extensions` module (issue #183 fixed via #184) (@solnic)
104
124
 
125
+ [1.5.1]: https://github.com/dry-rb/dry-struct/compare/v1.5.0...v1.5.1
105
126
 
106
- [Compare v1.5.0...v1.5.1](https://github.com/dry-rb/dry-struct/compare/v1.5.0...v1.5.1)
107
-
108
- ## 1.5.0 2022-10-15
109
-
127
+ ## [1.5.0] - 2022-10-15
110
128
 
111
129
  ### Changed
112
130
 
113
131
  - Use zeitwerk for auto-loading (@flash-gordon)
114
132
 
115
- [Compare v1.4.0...v1.5.0](https://github.com/dry-rb/dry-struct/compare/v1.4.0...v1.5.0)
116
-
117
- ## 1.4.0 2021-01-21
133
+ [1.5.0]: https://github.com/dry-rb/dry-struct/compare/v1.4.0...v1.5.0
118
134
 
135
+ ## [1.4.0] - 2021-01-21
119
136
 
120
137
  ### Added
121
138
 
@@ -132,11 +149,9 @@
132
149
  User.new(name: "John", address: nil) # => #<User name="John" address=nil>
133
150
  ```
134
151
 
152
+ [1.4.0]: https://github.com/dry-rb/dry-struct/compare/v1.3.0...v1.4.0
135
153
 
136
- [Compare v1.3.0...v1.4.0](https://github.com/dry-rb/dry-struct/compare/v1.3.0...v1.4.0)
137
-
138
- ## 1.3.0 2020-02-10
139
-
154
+ ## [1.3.0] - 2020-02-10
140
155
 
141
156
  ### Added
142
157
 
@@ -186,20 +201,18 @@
186
201
 
187
202
  - [internal] metadata is now stored inside schema (@flash-gordon)
188
203
 
189
- [Compare v1.2.0...v1.3.0](https://github.com/dry-rb/dry-struct/compare/v1.2.0...v1.3.0)
190
-
191
- ## 1.2.0 2019-12-20
204
+ [1.3.0]: https://github.com/dry-rb/dry-struct/compare/v1.2.0...v1.3.0
192
205
 
206
+ ## [1.2.0] - 2019-12-20
193
207
 
194
208
  ### Changed
195
209
 
196
210
  - `Dry::Struct::Value` is deprecated. `Dry::Struct` instances were never meant to be mutable, we have no support for this. The only difference between `Dry::Struct` and `Dry::Struct::Value` is that the latter is deeply frozen. Freezing objects slows the code down and gives you very little benefit in return. If you have a use case for `Value`, it won't be hard to roll your own solution using [ice_nine](https://github.com/dkubb/ice_nine) (flash-gordon)
197
211
  - In the thread of the previous change, structs now use immutable equalizer. This means `Struct#hash` memoizes its value after the first invocation. Depending on the case, this may speed up your code significantly (flash-gordon)
198
212
 
199
- [Compare v1.1.1...v1.2.0](https://github.com/dry-rb/dry-struct/compare/v1.1.1...v1.2.0)
200
-
201
- ## 1.1.1 2019-10-13
213
+ [1.2.0]: https://github.com/dry-rb/dry-struct/compare/v1.1.1...v1.2.0
202
214
 
215
+ ## [1.1.1] - 2019-10-13
203
216
 
204
217
  ### Changed
205
218
 
@@ -220,20 +233,17 @@
220
233
 
221
234
  See more examples in the [specs](https://github.com/dry-rb/dry-struct/blob/8112772eb08d22ff2cd3e6997514d79a9b124968/spec/dry/struct/pattern_matching_spec.rb).
222
235
 
223
- [Compare v1.1.0...v1.1.1](https://github.com/dry-rb/dry-struct/compare/v1.1.0...v1.1.1)
224
-
225
- ## 1.1.0 2019-10-07
236
+ [1.1.1]: https://github.com/dry-rb/dry-struct/compare/v1.1.0...v1.1.1
226
237
 
238
+ ## [1.1.0] - 2019-10-07
227
239
 
228
240
  ### Added
229
241
 
230
242
  - Experimental support for pattern matching :tada: (flash-gordon)
231
243
 
244
+ [1.1.0]: https://github.com/dry-rb/dry-struct/compare/v1.0.0...v1.1.0
232
245
 
233
- [Compare v1.0.0...v1.1.0](https://github.com/dry-rb/dry-struct/compare/v1.0.0...v1.1.0)
234
-
235
- ## 1.0.0 2019-04-23
236
-
246
+ ## [1.0.0] - 2019-04-23
237
247
 
238
248
  ### Added
239
249
 
@@ -248,10 +258,9 @@
248
258
 
249
259
  - `valid?` and `===` behave differently, `===` works the same way `Class#===` does and `valid?` checks if the value _can be_ coerced to the struct (flash-gordon)
250
260
 
251
- [Compare v0.7.0...v1.0.0](https://github.com/dry-rb/dry-struct/compare/v0.7.0...v1.0.0)
252
-
253
- ## 0.7.0 2019-03-22
261
+ [1.0.0]: https://github.com/dry-rb/dry-struct/compare/v0.7.0...v1.0.0
254
262
 
263
+ ## [0.7.0] - 2019-03-22
255
264
 
256
265
  ### Changed
257
266
 
@@ -278,10 +287,9 @@
278
287
  - `Dry::Stuct#new` is now more efficient for partial updates (flash-gordon)
279
288
  - Ruby 2.3 is EOL and not officially supported. It may work but we don't test it.
280
289
 
281
- [Compare v0.6.0...v0.7.0](https://github.com/dry-rb/dry-struct/compare/v0.6.0...v0.7.0)
282
-
283
- ## 0.6.0 2018-10-24
290
+ [0.7.0]: https://github.com/dry-rb/dry-struct/compare/v0.6.0...v0.7.0
284
291
 
292
+ ## [0.6.0] - 2018-10-24
285
293
 
286
294
  ### Added
287
295
 
@@ -303,10 +311,9 @@
303
311
 
304
312
  - [BREAKING] `Struct.attribute?` in the old sense is deprecated, use `has_attribute?` as a replacement
305
313
 
306
- [Compare v0.5.1...v0.6.0](https://github.com/dry-rb/dry-struct/compare/v0.5.1...v0.6.0)
307
-
308
- ## 0.5.1 2018-08-11
314
+ [0.6.0]: https://github.com/dry-rb/dry-struct/compare/v0.5.1...v0.6.0
309
315
 
316
+ ## [0.5.1] - 2018-08-11
310
317
 
311
318
  ### Added
312
319
 
@@ -324,11 +331,9 @@
324
331
 
325
332
  - Constant resolution is now restricted to the current module when structs are automatically defined using the block syntax. This shouldn't break any existing code (piktur)
326
333
 
334
+ [0.5.1]: https://github.com/dry-rb/dry-struct/compare/v0.5.0...v0.5.1
327
335
 
328
- [Compare v0.5.0...v0.5.1](https://github.com/dry-rb/dry-struct/compare/v0.5.0...v0.5.1)
329
-
330
- ## 0.5.0 2018-05-03
331
-
336
+ ## [0.5.0] - 2018-05-03
332
337
 
333
338
  ### Added
334
339
 
@@ -385,11 +390,9 @@
385
390
  - Adding a new attribute invalidates `attribute_names` (flash-gordon)
386
391
  - Struct classes track subclasses and define attributes in them, now it doesn't matter whether you define attributes first and _then_ subclass or vice versa. Note this can lead to memory leaks in Rails environment when struct classes are reloaded (flash-gordon)
387
392
 
393
+ [0.5.0]: https://github.com/dry-rb/dry-struct/compare/v0.4.0...v0.5.0
388
394
 
389
- [Compare v0.4.0...v0.5.0](https://github.com/dry-rb/dry-struct/compare/v0.4.0...v0.5.0)
390
-
391
- ## 0.4.0 2017-11-04
392
-
395
+ ## [0.4.0] - 2017-11-04
393
396
 
394
397
  ### Fixed
395
398
 
@@ -401,10 +404,9 @@
401
404
  - `Struct#new` uses raw attributes instead of method calls, this makes the behavior consistent with the change above (flash-gordon)
402
405
  - `constructor_type` now actively rejects `:weak` and `:symbolized` values (GustavoCaso)
403
406
 
404
- [Compare v0.3.1...v0.4.0](https://github.com/dry-rb/dry-struct/compare/v0.3.1...v0.4.0)
405
-
406
- ## 0.3.1 2017-06-30
407
+ [0.4.0]: https://github.com/dry-rb/dry-struct/compare/v0.3.1...v0.4.0
407
408
 
409
+ ## [0.3.1] - 2017-06-30
408
410
 
409
411
  ### Added
410
412
 
@@ -412,11 +414,9 @@
412
414
  - `Struct.attribute?` and `Struct.attribute_names` for introspecting struct attributes (flash-gordon)
413
415
  - `Struct#__new__` is a safe-to-use-in-gems alias for `Struct#new` (flash-gordon)
414
416
 
417
+ [0.3.1]: https://github.com/dry-rb/dry-struct/compare/v0.3.0...v0.3.1
415
418
 
416
- [Compare v0.3.0...v0.3.1](https://github.com/dry-rb/dry-struct/compare/v0.3.0...v0.3.1)
417
-
418
- ## 0.3.0 2017-05-05
419
-
419
+ ## [0.3.0] - 2017-05-05
420
420
 
421
421
  ### Added
422
422
 
@@ -431,39 +431,33 @@
431
431
 
432
432
  - `.new` without arguments doesn't use nil as an input for non-default types anymore (flash-gordon)
433
433
 
434
- [Compare v0.2.1...v0.3.0](https://github.com/dry-rb/dry-struct/compare/v0.2.1...v0.3.0)
435
-
436
- ## 0.2.1 2017-02-27
434
+ [0.3.0]: https://github.com/dry-rb/dry-struct/compare/v0.2.1...v0.3.0
437
435
 
436
+ ## [0.2.1] - 2017-02-27
438
437
 
439
438
  ### Fixed
440
439
 
441
440
  - Fixed `Dry::Struct::Value` which appeared to be broken in the last release (flash-gordon)
442
441
 
442
+ [0.2.1]: https://github.com/dry-rb/dry-struct/compare/v0.2.0...v0.2.1
443
443
 
444
- [Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-struct/compare/v0.2.0...v0.2.1)
445
-
446
- ## 0.2.0 2016-02-26
447
-
444
+ ## [0.2.0] - 2016-02-26
448
445
 
449
446
  ### Changed
450
447
 
451
448
  - Struct attributes can be overridden in a subclass (flash-gordon)
452
449
 
453
- [Compare v0.1.1...v0.2.0](https://github.com/dry-rb/dry-struct/compare/v0.1.1...v0.2.0)
454
-
455
- ## 0.1.1 2016-11-13
450
+ [0.2.0]: https://github.com/dry-rb/dry-struct/compare/v0.1.1...v0.2.0
456
451
 
452
+ ## [0.1.1] - 2016-11-13
457
453
 
458
454
  ### Fixed
459
455
 
460
456
  - Make `Dry::Struct` act as a constrained type. This fixes the behavior of sum types containing structs (flash-gordon)
461
457
 
458
+ [0.1.1]: https://github.com/dry-rb/dry-struct/compare/v0.1.0...v0.1.1
462
459
 
463
- [Compare v0.1.0...v0.1.1](https://github.com/dry-rb/dry-struct/compare/v0.1.0...v0.1.1)
464
-
465
- ## 0.1.0 2016-09-21
466
-
460
+ ## [0.1.0] - 2016-09-21
467
461
 
468
462
  ### Added
469
463
 
@@ -475,8 +469,10 @@
475
469
  - [BREAKING] `:strict` now raises on unexpected keys (backus)
476
470
  - Structs no longer auto-register themselves in the types container as they implement `Type` interface and we don't have to wrap them in `Type::Definition` (flash-gordon)
477
471
 
478
- [Compare v0.0.1...v0.1.0](https://github.com/dry-rb/dry-struct/compare/v0.0.1...v0.1.0)
472
+ [0.1.0]: https://github.com/dry-rb/dry-struct/compare/v0.0.1...v0.1.0
479
473
 
480
- ## 0.0.1 2016-07-17
474
+ ## [0.0.1] - 2016-07-17
481
475
 
482
476
  Initial release of code imported from dry-types
477
+
478
+ [0.0.1]: https://github.com/dry-rb/dry-struct/releases/tag/v0.0.1
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2023 dry-rb team
3
+ Copyright (c) 2015-2026 Hanakai team
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -1,22 +1,17 @@
1
- <!--- this file is synced from dry-rb/template-gem project -->
2
- [gem]: https://rubygems.org/gems/dry-struct
1
+ <!--- This file is synced from hanakai-rb/repo-sync -->
2
+
3
+ [rubygem]: https://rubygems.org/gems/dry-struct
3
4
  [actions]: https://github.com/dry-rb/dry-struct/actions
4
5
 
5
- # dry-struct [![Gem Version](https://badge.fury.io/rb/dry-struct.svg)][gem] [![CI Status](https://github.com/dry-rb/dry-struct/workflows/CI/badge.svg)][actions]
6
+ # dry-struct [![Gem Version](https://badge.fury.io/rb/dry-struct.svg)][rubygem] [![CI Status](https://github.com/dry-rb/dry-struct/workflows/CI/badge.svg)][actions]
6
7
 
7
8
  ## Links
8
9
 
9
- * [User documentation](https://dry-rb.org/gems/dry-struct)
10
- * [API documentation](http://rubydoc.info/gems/dry-struct)
11
- * [Forum](https://discourse.dry-rb.org)
12
-
13
- ## Supported Ruby versions
14
-
15
- This library officially supports the following Ruby versions:
16
-
17
- * MRI `>= 3.1`
18
- * jruby `>= 9.4` (not tested on CI)
10
+ - [User documentation](https://dry-rb.org/gems/dry-struct)
11
+ - [API documentation](http://rubydoc.info/gems/dry-struct)
12
+ - [Forum](https://discourse.dry-rb.org)
19
13
 
20
14
  ## License
21
15
 
22
16
  See `LICENSE` file.
17
+
data/dry-struct.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # this file is synced from dry-rb/template-gem project
3
+ # This file is synced from hanakai-rb/repo-sync. To update it, edit repo-sync.yml.
4
4
 
5
5
  lib = File.expand_path("lib", __dir__)
6
6
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -8,8 +8,8 @@ require "dry/struct/version"
8
8
 
9
9
  Gem::Specification.new do |spec|
10
10
  spec.name = "dry-struct"
11
- spec.authors = ["Piotr Solnica"]
12
- spec.email = ["piotr.solnica@gmail.com"]
11
+ spec.authors = ["Hanakai team"]
12
+ spec.email = ["info@hanakai.org"]
13
13
  spec.license = "MIT"
14
14
  spec.version = Dry::Struct::VERSION.dup
15
15
 
@@ -17,21 +17,27 @@ Gem::Specification.new do |spec|
17
17
  spec.description = spec.summary
18
18
  spec.homepage = "https://dry-rb.org/gems/dry-struct"
19
19
  spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-struct.gemspec", "lib/**/*"]
20
- spec.bindir = "bin"
21
- spec.executables = []
20
+ spec.bindir = "exe"
21
+ spec.executables = Dir["exe/*"].map { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
25
- spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-struct/blob/main/CHANGELOG.md"
26
- spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-struct"
27
- spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-struct/issues"
28
- spec.metadata["rubygems_mfa_required"] = "true"
24
+ spec.extra_rdoc_files = ["README.md", "CHANGELOG.md", "LICENSE"]
25
+
26
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
27
+ spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-struct/blob/main/CHANGELOG.md"
28
+ spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-struct"
29
+ spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-struct/issues"
30
+ spec.metadata["funding_uri"] = "https://github.com/sponsors/hanami"
29
31
 
30
32
  spec.required_ruby_version = ">= 3.1.0"
31
33
 
32
- # to update dependencies edit project.yml
33
- spec.add_dependency "dry-core", "~> 1.1"
34
- spec.add_dependency "dry-types", "~> 1.8", ">= 1.8.2"
35
- spec.add_dependency "ice_nine", "~> 0.11"
36
- spec.add_dependency "zeitwerk", "~> 2.6"
34
+ spec.add_runtime_dependency "zeitwerk", "~> 2.6"
35
+ spec.add_runtime_dependency "dry-core", "~> 1.1"
36
+ spec.add_runtime_dependency "dry-types", "~> 1.8", ">= 1.8.2"
37
+ spec.add_runtime_dependency "ice_nine", "~> 0.11"
38
+ spec.add_development_dependency "bundler"
39
+ spec.add_development_dependency "rake"
40
+ spec.add_development_dependency "rspec"
41
+ spec.add_development_dependency "yard"
37
42
  end
43
+
@@ -5,7 +5,7 @@ require "weakref"
5
5
  module Dry
6
6
  class Struct
7
7
  # Class-level interface of {Struct} and {Value}
8
- module ClassInterface # rubocop:disable Metrics/ModuleLength
8
+ module ClassInterface
9
9
  include Core::ClassAttributes
10
10
 
11
11
  include Types::Type
@@ -236,7 +236,7 @@ module Dry
236
236
 
237
237
  # @param [Hash{Symbol => Object},Dry::Struct] attributes
238
238
  # @raise [Struct::Error] if the given attributes don't conform {#schema}
239
- def new(attributes = default_attributes, safe = false, &) # rubocop:disable Style/OptionalBooleanParameter
239
+ def new(attributes = default_attributes, safe = false, &)
240
240
  if attributes.is_a?(Struct)
241
241
  if equal?(attributes.class)
242
242
  attributes
@@ -253,8 +253,8 @@ module Dry
253
253
  else
254
254
  load(schema.call_unsafe(attributes))
255
255
  end
256
- rescue Types::CoercionError => e
257
- raise Error, "[#{self}.new] #{e}", e.backtrace
256
+ rescue Types::CoercionError => exception
257
+ raise Error, "[#{self}.new] #{exception}", exception.backtrace
258
258
  end
259
259
 
260
260
  # @api private
@@ -295,8 +295,8 @@ module Dry
295
295
  # @return [Dry::Types::Result]
296
296
  def try(input)
297
297
  success(self[input])
298
- rescue Error => e
299
- failure_result = failure(input, e)
298
+ rescue Error => exception
299
+ failure_result = failure(input, exception)
300
300
  block_given? ? yield(failure_result) : failure_result
301
301
  end
302
302
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "pp" # rubocop:disable Lint/RedundantRequireStatement
3
+ require "pp"
4
4
 
5
5
  module Dry
6
6
  class Struct
@@ -5,11 +5,11 @@ module Dry
5
5
  # Helper for {Struct#to_hash} implementation
6
6
  module Hashify
7
7
  # Converts value to hash recursively
8
- # @param [#to_hash, #map, Object] value
8
+ # @param [#to_hash, #to_ary, Object] value
9
9
  # @return [Hash, Array]
10
10
  def self.[](value)
11
- if value.is_a?(Struct)
12
- value.to_h.transform_values { self[_1] }
11
+ if value.is_a?(::Dry::Struct)
12
+ value.to_h
13
13
  elsif value.respond_to?(:to_hash)
14
14
  value.to_hash.transform_values { self[_1] }
15
15
  elsif value.respond_to?(:to_ary)
@@ -3,6 +3,6 @@
3
3
  module Dry
4
4
  class Struct
5
5
  # @private
6
- VERSION = "1.8.0"
6
+ VERSION = "1.8.1"
7
7
  end
8
8
  end
data/lib/dry/struct.rb CHANGED
@@ -206,8 +206,8 @@ module Dry
206
206
  resolve_defaults: false
207
207
  )
208
208
  self.class.load(__attributes__.merge(new_attributes))
209
- rescue Types::SchemaError, Types::MissingKeyError, Types::UnknownKeysError => e
210
- raise Error, "[#{self}.new] #{e}"
209
+ rescue Types::SchemaError, Types::MissingKeyError, Types::UnknownKeysError => exception
210
+ raise Error, "[#{self}.new] #{exception}"
211
211
  end
212
212
  alias_method :__new__, :new
213
213
 
metadata CHANGED
@@ -1,15 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.8.1
5
5
  platform: ruby
6
6
  authors:
7
- - Piotr Solnica
8
- autorequire:
9
- bindir: bin
7
+ - Hanakai team
8
+ bindir: exe
10
9
  cert_chain: []
11
- date: 2025-03-09 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: zeitwerk
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '2.6'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '2.6'
13
26
  - !ruby/object:Gem::Dependency
14
27
  name: dry-core
15
28
  requirement: !ruby/object:Gem::Requirement
@@ -59,25 +72,70 @@ dependencies:
59
72
  - !ruby/object:Gem::Version
60
73
  version: '0.11'
61
74
  - !ruby/object:Gem::Dependency
62
- name: zeitwerk
75
+ name: bundler
63
76
  requirement: !ruby/object:Gem::Requirement
64
77
  requirements:
65
- - - "~>"
78
+ - - ">="
66
79
  - !ruby/object:Gem::Version
67
- version: '2.6'
68
- type: :runtime
80
+ version: '0'
81
+ type: :development
69
82
  prerelease: false
70
83
  version_requirements: !ruby/object:Gem::Requirement
71
84
  requirements:
72
- - - "~>"
85
+ - - ">="
73
86
  - !ruby/object:Gem::Version
74
- version: '2.6'
87
+ version: '0'
88
+ - !ruby/object:Gem::Dependency
89
+ name: rake
90
+ requirement: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ type: :development
96
+ prerelease: false
97
+ version_requirements: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ - !ruby/object:Gem::Dependency
103
+ name: rspec
104
+ requirement: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ type: :development
110
+ prerelease: false
111
+ version_requirements: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ - !ruby/object:Gem::Dependency
117
+ name: yard
118
+ requirement: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ type: :development
124
+ prerelease: false
125
+ version_requirements: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
75
130
  description: Typed structs and value objects
76
131
  email:
77
- - piotr.solnica@gmail.com
132
+ - info@hanakai.org
78
133
  executables: []
79
134
  extensions: []
80
- extra_rdoc_files: []
135
+ extra_rdoc_files:
136
+ - CHANGELOG.md
137
+ - LICENSE
138
+ - README.md
81
139
  files:
82
140
  - CHANGELOG.md
83
141
  - LICENSE
@@ -106,8 +164,7 @@ metadata:
106
164
  changelog_uri: https://github.com/dry-rb/dry-struct/blob/main/CHANGELOG.md
107
165
  source_code_uri: https://github.com/dry-rb/dry-struct
108
166
  bug_tracker_uri: https://github.com/dry-rb/dry-struct/issues
109
- rubygems_mfa_required: 'true'
110
- post_install_message:
167
+ funding_uri: https://github.com/sponsors/hanami
111
168
  rdoc_options: []
112
169
  require_paths:
113
170
  - lib
@@ -122,8 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
179
  - !ruby/object:Gem::Version
123
180
  version: '0'
124
181
  requirements: []
125
- rubygems_version: 3.3.27
126
- signing_key:
182
+ rubygems_version: 3.6.9
127
183
  specification_version: 4
128
184
  summary: Typed structs and value objects
129
185
  test_files: []