dry-initializer 3.0.1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +259 -242
- data/LICENSE +20 -0
- data/README.md +18 -78
- data/dry-initializer.gemspec +34 -19
- data/lib/dry/initializer/builders/attribute.rb +84 -69
- data/lib/dry/initializer/builders/initializer.rb +56 -58
- data/lib/dry/initializer/builders/reader.rb +55 -47
- data/lib/dry/initializer/builders/signature.rb +29 -23
- data/lib/dry/initializer/builders.rb +9 -5
- data/lib/dry/initializer/config.rb +162 -158
- data/lib/dry/initializer/definition.rb +58 -54
- data/lib/dry/initializer/dispatchers/build_nested_type.rb +54 -40
- data/lib/dry/initializer/dispatchers/check_type.rb +45 -39
- data/lib/dry/initializer/dispatchers/prepare_default.rb +32 -25
- data/lib/dry/initializer/dispatchers/prepare_ivar.rb +13 -6
- data/lib/dry/initializer/dispatchers/prepare_optional.rb +14 -7
- data/lib/dry/initializer/dispatchers/prepare_reader.rb +29 -22
- data/lib/dry/initializer/dispatchers/prepare_source.rb +12 -5
- data/lib/dry/initializer/dispatchers/prepare_target.rb +44 -37
- data/lib/dry/initializer/dispatchers/unwrap_type.rb +21 -10
- data/lib/dry/initializer/dispatchers/wrap_type.rb +25 -17
- data/lib/dry/initializer/dispatchers.rb +48 -43
- data/lib/dry/initializer/dsl.rb +42 -34
- data/lib/dry/initializer/errors.rb +22 -0
- data/lib/dry/initializer/mixin/local.rb +19 -13
- data/lib/dry/initializer/mixin/root.rb +12 -6
- data/lib/dry/initializer/mixin.rb +17 -12
- data/lib/dry/initializer/struct.rb +34 -30
- data/lib/dry/initializer/undefined.rb +7 -1
- data/lib/dry/initializer/version.rb +7 -0
- data/lib/dry/initializer.rb +3 -0
- data/lib/dry-initializer.rb +2 -0
- data/lib/tasks/benchmark.rake +2 -0
- data/lib/tasks/profile.rake +4 -0
- metadata +27 -106
- data/.codeclimate.yml +0 -23
- data/.gitignore +0 -10
- data/.rspec +0 -4
- data/.rubocop.yml +0 -51
- data/.travis.yml +0 -28
- data/Gemfile +0 -29
- data/Guardfile +0 -5
- data/LICENSE.txt +0 -21
- data/Rakefile +0 -8
- data/benchmarks/compare_several_defaults.rb +0 -82
- data/benchmarks/plain_options.rb +0 -63
- data/benchmarks/plain_params.rb +0 -84
- data/benchmarks/with_coercion.rb +0 -71
- data/benchmarks/with_defaults.rb +0 -66
- data/benchmarks/with_defaults_and_coercion.rb +0 -59
- data/spec/attributes_spec.rb +0 -38
- data/spec/coercion_of_nil_spec.rb +0 -25
- data/spec/custom_dispatchers_spec.rb +0 -35
- data/spec/custom_initializer_spec.rb +0 -30
- data/spec/default_values_spec.rb +0 -83
- data/spec/definition_spec.rb +0 -111
- data/spec/invalid_default_spec.rb +0 -13
- data/spec/list_type_spec.rb +0 -32
- data/spec/missed_default_spec.rb +0 -14
- data/spec/nested_type_spec.rb +0 -44
- data/spec/optional_spec.rb +0 -71
- data/spec/options_tolerance_spec.rb +0 -11
- data/spec/public_attributes_utility_spec.rb +0 -22
- data/spec/reader_spec.rb +0 -87
- data/spec/repetitive_definitions_spec.rb +0 -69
- data/spec/several_assignments_spec.rb +0 -41
- data/spec/spec_helper.rb +0 -22
- data/spec/subclassing_spec.rb +0 -49
- data/spec/type_argument_spec.rb +0 -35
- data/spec/type_constraint_spec.rb +0 -78
- data/spec/value_coercion_via_dry_types_spec.rb +0 -29
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,47 @@
|
|
1
|
-
|
1
|
+
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
|
2
2
|
|
3
|
-
|
3
|
+
## 3.1.0 2022-01-16
|
4
4
|
|
5
|
-
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
6
|
-
and this project adheres to [Semantic Versioning](http://semver.org/).
|
7
5
|
|
8
|
-
|
6
|
+
### Changed
|
7
|
+
|
8
|
+
- Improved error messages on type mismatch (@swerling)
|
9
|
+
- [BREAKING] Minimal supported Ruby version is 2.7 (@flash-gordon)
|
10
|
+
|
11
|
+
[Compare v3.0.4...v3.1.0](https://github.com/dry-rb/dry-initializer/compare/v3.0.4...v3.1.0)
|
12
|
+
|
13
|
+
## 3.0.4 2020-09-29
|
14
|
+
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
|
18
|
+
- Arity check for lambdas used for coercion (@flash-gordon)
|
19
|
+
|
20
|
+
|
21
|
+
[Compare v3.0.3...v3.0.4](https://github.com/dry-rb/dry-initializer/compare/v3.0.3...v3.0.4)
|
22
|
+
|
23
|
+
## 3.0.3 2020-01-08
|
24
|
+
|
25
|
+
|
26
|
+
### Fixed
|
27
|
+
|
28
|
+
- Constrained member arrays work correctly now (see #33) (@bjeanes + @solnic)
|
29
|
+
|
30
|
+
|
31
|
+
[Compare v3.0.2...v3.0.3](https://github.com/dry-rb/dry-initializer/compare/v3.0.2...v3.0.3)
|
32
|
+
|
33
|
+
## 3.0.2 2019-11-07
|
34
|
+
|
35
|
+
|
36
|
+
### Fixed
|
37
|
+
|
38
|
+
- Warnings about keyword arguments (flash-gordon)
|
39
|
+
|
40
|
+
|
41
|
+
[Compare v3.0.1...v3.0.2](https://github.com/dry-rb/dry-initializer/compare/v3.0.1...v3.0.2)
|
42
|
+
|
43
|
+
## 3.0.1 2019-04-15
|
44
|
+
|
9
45
|
|
10
46
|
### Fixed
|
11
47
|
|
@@ -39,7 +75,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
39
75
|
This restriction is necessary because we constantize option/param names
|
40
76
|
when defining nested structs.
|
41
77
|
|
42
|
-
|
78
|
+
|
79
|
+
[Compare v3.0.0...v3.0.1](https://github.com/dry-rb/dry-initializer/compare/v3.0.0...v3.0.1)
|
80
|
+
|
81
|
+
## 3.0.0 2019-04-14
|
82
|
+
|
43
83
|
|
44
84
|
### Added
|
45
85
|
|
@@ -55,7 +95,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
55
95
|
test = Test.new(42)
|
56
96
|
test.foo # => ["42"]
|
57
97
|
```
|
58
|
-
|
59
98
|
- It works with several layers of nesting (nepalez)
|
60
99
|
|
61
100
|
```ruby
|
@@ -68,7 +107,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
68
107
|
test = Test.new(42)
|
69
108
|
test.foo # => [["42"]]
|
70
109
|
```
|
71
|
-
|
72
110
|
- Support of nested types/coercers (nepalez)
|
73
111
|
|
74
112
|
```ruby
|
@@ -83,7 +121,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
83
121
|
test = Test.new(bar: { "baz" => 42 })
|
84
122
|
test.foo.bar.baz # => "42"
|
85
123
|
```
|
86
|
-
|
87
124
|
- Wrapped/nested combinations are supported as well (nepalez)
|
88
125
|
|
89
126
|
```ruby
|
@@ -96,8 +133,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
96
133
|
test = Test.new(bar: 42)
|
97
134
|
test.foo.first.bar # => "42"
|
98
135
|
```
|
99
|
-
|
100
|
-
## [2.7.0] Unreleazed
|
136
|
+
- ## [2.7.0] Unreleazed
|
101
137
|
|
102
138
|
### Fixed
|
103
139
|
|
@@ -109,10 +145,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
109
145
|
The version [2.6.0] has been yanked on rubygems, so the master
|
110
146
|
was rolled back to the previous state until the reason for
|
111
147
|
the incompatibility become clear (bjeanes, nepalez)
|
148
|
+
- ## [2.6.0] [2018-09-09] (YANKED)
|
149
|
+
|
112
150
|
|
113
|
-
|
151
|
+
[Compare v2.5.0...v3.0.0](https://github.com/dry-rb/dry-initializer/compare/v2.5.0...v3.0.0)
|
152
|
+
|
153
|
+
## 2.5.0 2018-08-17
|
114
154
|
|
115
|
-
## [2.5.0] [2018-08-17]
|
116
155
|
|
117
156
|
### Fixed
|
118
157
|
|
@@ -122,9 +161,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
122
161
|
the coercion should be applied to any value, including `nil`, because
|
123
162
|
we cannot distinct "undefined" `nil` from the "assigned" `nil` value.
|
124
163
|
|
125
|
-
|
164
|
+
|
165
|
+
[Compare v2.4.0...v2.5.0](https://github.com/dry-rb/dry-initializer/compare/v2.4.0...v2.5.0)
|
166
|
+
|
167
|
+
## 2.4.0 2018-02-01
|
168
|
+
|
126
169
|
|
127
170
|
### Added
|
171
|
+
|
128
172
|
- Dispatchers for adding syntax sugar to `param` and `options` (nepalez)
|
129
173
|
|
130
174
|
```ruby
|
@@ -138,9 +182,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
138
182
|
end
|
139
183
|
```
|
140
184
|
|
141
|
-
|
185
|
+
|
186
|
+
[Compare v2.3.0...v2.4.0](https://github.com/dry-rb/dry-initializer/compare/v2.3.0...v2.4.0)
|
187
|
+
|
188
|
+
## 2.3.0 2017-09-19
|
189
|
+
|
142
190
|
|
143
191
|
### Added
|
192
|
+
|
144
193
|
- Type coercer can take second argument for the initialized instance (nepalez)
|
145
194
|
This allows to wrap assigned value to the object that refers back
|
146
195
|
to the initializer instance. More verbose example:
|
@@ -148,7 +197,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
148
197
|
```ruby
|
149
198
|
class Location < String
|
150
199
|
attr_reader :parameter # refers back to its parameter
|
151
|
-
|
200
|
+
|
152
201
|
def initialize(name, parameter)
|
153
202
|
super(name)
|
154
203
|
@parameter = parameter
|
@@ -167,11 +216,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
167
216
|
offset.location.parameter == offset # true
|
168
217
|
```
|
169
218
|
|
170
|
-
|
219
|
+
|
220
|
+
[Compare v2.2.0...v2.3.0](https://github.com/dry-rb/dry-initializer/compare/v2.2.0...v2.3.0)
|
221
|
+
|
222
|
+
## 2.2.0 2017-09-13
|
223
|
+
|
171
224
|
|
172
225
|
### Added
|
173
|
-
- Option `:desc` for option/param to add a description (nepalez)
|
174
226
|
|
227
|
+
- Option `:desc` for option/param to add a description (nepalez)
|
175
228
|
- Methods `Definition#inch` and `Config#inch` to inspect definitions (nepalez)
|
176
229
|
|
177
230
|
```ruby
|
@@ -189,9 +242,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
189
242
|
# @return [User]
|
190
243
|
```
|
191
244
|
|
192
|
-
|
245
|
+
|
246
|
+
[Compare v2.1.0...v2.2.0](https://github.com/dry-rb/dry-initializer/compare/v2.1.0...v2.2.0)
|
247
|
+
|
248
|
+
## 2.1.0 2017-09-11
|
249
|
+
|
193
250
|
|
194
251
|
### Added
|
252
|
+
|
195
253
|
- Method `#options` to param/option definition (nepalez)
|
196
254
|
|
197
255
|
```ruby
|
@@ -213,28 +271,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
213
271
|
This method can be helpful for replicating params/options
|
214
272
|
in another class without inheritance.
|
215
273
|
|
216
|
-
## [2.0.0] [2017-08-28]
|
217
274
|
|
218
|
-
|
219
|
-
interface about the same (see "Deleted" section below for the only
|
220
|
-
backward-incompatible change).
|
275
|
+
[Compare v2.0.0...v2.1.0](https://github.com/dry-rb/dry-initializer/compare/v2.0.0...v2.1.0)
|
221
276
|
|
222
|
-
|
223
|
-
change in params/options of superclass wasn't reflected in its
|
224
|
-
previously declared subclasses.
|
277
|
+
## 2.0.0 2017-08-28
|
225
278
|
|
226
|
-
Thanks to @solnic for the idea of class-level container,
|
227
279
|
and to @gzigzigzeo for persuading me to do this refactoring.
|
228
280
|
|
229
|
-
### Deleted
|
230
|
-
- Undocumented variable `@__option__` which was the main reason for refactoring
|
231
|
-
(gzigzigzeo, nepalez).
|
232
|
-
|
233
281
|
### Added
|
282
|
+
|
234
283
|
- Class method `.dry_initializer` -- a container for `.params` and `.options`
|
235
284
|
`.definitions` along with the `.null` setting (either `nil` or `UNDEFINED`)
|
236
285
|
used for unassigned values (nepalez)
|
237
|
-
|
238
286
|
- `.dry_initializer.attributes` method takes an instance of the same class
|
239
287
|
and returns the hash of assigned options. This provide the same
|
240
288
|
functionality as previously used instance variable `@__options__` (nepalez)
|
@@ -253,7 +301,6 @@ and to @gzigzigzeo for persuading me to do this refactoring.
|
|
253
301
|
|
254
302
|
Both methods `.dry_initializer` and `#__dry_initializer_config__` refer
|
255
303
|
to the same object.
|
256
|
-
|
257
304
|
- `.dry_initializer.public_attributes`. This method works differently:
|
258
305
|
it looks through (possibly reloaded) readers instead of variables
|
259
306
|
(gzigzigzeo, nepalez)
|
@@ -265,6 +312,7 @@ and to @gzigzigzeo for persuading me to do this refactoring.
|
|
265
312
|
You can use the same trick as above mutatis mutandis.
|
266
313
|
|
267
314
|
### Fixed
|
315
|
+
|
268
316
|
- Definition order dependency bug (nepalez)
|
269
317
|
|
270
318
|
I've found out that if you provided a subclass and then changed params
|
@@ -276,7 +324,6 @@ and to @gzigzigzeo for persuading me to do this refactoring.
|
|
276
324
|
of the tree, and reloads their defintitions.
|
277
325
|
|
278
326
|
Being done in load time, the rebuilt makes no effect on runtime performance.
|
279
|
-
|
280
327
|
- Possible misbehavior when you define param and option with the same name (nepalez)
|
281
328
|
|
282
329
|
Doing this will provide `option :name` only, not both:
|
@@ -285,7 +332,6 @@ and to @gzigzigzeo for persuading me to do this refactoring.
|
|
285
332
|
param :name
|
286
333
|
option :name
|
287
334
|
```
|
288
|
-
|
289
335
|
- Attempt to redefine param/option of superclass with option/param in
|
290
336
|
its subclass will cause an exception because it would break
|
291
337
|
Liskov substitute principle with unexpected behaviour (nepalez)
|
@@ -302,7 +348,6 @@ and to @gzigzigzeo for persuading me to do this refactoring.
|
|
302
348
|
option :name
|
303
349
|
end
|
304
350
|
```
|
305
|
-
|
306
351
|
- When you reloading previously defined param of superclass, the gem
|
307
352
|
will check all its descendands for whether all required positional params
|
308
353
|
goes before optional ones (nepalez)
|
@@ -327,6 +372,7 @@ and to @gzigzigzeo for persuading me to do this refactoring.
|
|
327
372
|
```
|
328
373
|
|
329
374
|
### Changed
|
375
|
+
|
330
376
|
- Under the hood I've separated param/option settings declaration (a container
|
331
377
|
with param/option settings) from code builders for initializer and readers
|
332
378
|
(nepalez)
|
@@ -359,7 +405,6 @@ and to @gzigzigzeo for persuading me to do this refactoring.
|
|
359
405
|
|
360
406
|
You can check null value via `.dry_initializer.null` which is different
|
361
407
|
for `Dry::Initializer` and `Dry::Initializer[undefined: false]` modules.
|
362
|
-
|
363
408
|
- Optimized the code for `__initializer__`-s (the method where all magics occurs)
|
364
409
|
(nepalez)
|
365
410
|
|
@@ -410,33 +455,40 @@ and to @gzigzigzeo for persuading me to do this refactoring.
|
|
410
455
|
virtus: 180272.6 i/s - 15.99x slower
|
411
456
|
```
|
412
457
|
|
413
|
-
|
458
|
+
[Compare v1.4.1...v2.0.0](https://github.com/dry-rb/dry-initializer/compare/v1.4.1...v2.0.0)
|
459
|
+
|
460
|
+
## 1.4.1 2017-04-05
|
461
|
+
|
414
462
|
|
415
463
|
### Fixed
|
464
|
+
|
416
465
|
- Warning about redefined `#initialize` in case the method reloaded in a klass
|
417
466
|
that extends the module (nepalez, sergey-chechaev)
|
418
467
|
|
419
468
|
### Changed
|
469
|
+
|
420
470
|
- Rename `Dry::Initializer::DSL` -> `Dry::Initializer::ClassDSL` (nepalez)
|
421
471
|
- Add `Dry::Initializer::InstanceDSL` (nepalez)
|
422
472
|
|
423
|
-
|
424
|
-
- `Dry::Initializer::Mixin`. In latest version this was an alias for
|
425
|
-
`Dry::Initializer` that kept for backward compatibility for early versions of the gem.
|
473
|
+
[Compare v1.4.0...v1.4.1](https://github.com/dry-rb/dry-initializer/compare/v1.4.0...v1.4.1)
|
426
474
|
|
427
|
-
|
475
|
+
## 1.4.0 2017-03-08
|
428
476
|
|
429
|
-
## [1.4.0] [2017-03-08]
|
430
477
|
|
431
|
-
### Changed
|
478
|
+
### Changed
|
479
|
+
|
432
480
|
- The `@__options__` hash now collects all assigned attributes,
|
433
481
|
collected via `#option` (as before), and `#param` (nepalez)
|
434
482
|
|
435
|
-
|
483
|
+
[Compare v1.3.0...v1.4.0](https://github.com/dry-rb/dry-initializer/compare/v1.3.0...v1.4.0)
|
484
|
+
|
485
|
+
## 1.3.0 2017-03-05
|
486
|
+
|
436
487
|
|
437
488
|
### Added
|
489
|
+
|
438
490
|
- No-undefined configuration of the initializer (nepalez, flash-gordon)
|
439
|
-
|
491
|
+
|
440
492
|
You can either extend or include module `Dry::Initializer` with additional option
|
441
493
|
`[undefined: false]`. This time `nil` will be assigned instead of
|
442
494
|
`Dry::Initializer::UNDEFINED`. Readers becomes faster because there is no need
|
@@ -457,31 +509,55 @@ and to @gzigzigzeo for persuading me to do this refactoring.
|
|
457
509
|
Bar.new.instance_variable_get(:@qux) # => nil
|
458
510
|
|
459
511
|
### Changed
|
512
|
+
|
460
513
|
- Fixed method definitions for performance at the load time (nepalez, flash-gordon)
|
461
514
|
|
462
|
-
|
515
|
+
[Compare v1.2.0...v1.3.0](https://github.com/dry-rb/dry-initializer/compare/v1.2.0...v1.3.0)
|
516
|
+
|
517
|
+
## 1.2.0 2017-03-05
|
518
|
+
|
463
519
|
|
464
520
|
### Fixed
|
521
|
+
|
465
522
|
- The `@__options__` variable collects renamed options after default values and coercions were applied (nepalez)
|
466
523
|
|
467
|
-
|
524
|
+
|
525
|
+
[Compare v1.1.3...v1.2.0](https://github.com/dry-rb/dry-initializer/compare/v1.1.3...v1.2.0)
|
526
|
+
|
527
|
+
## 1.1.3 2017-03-01
|
528
|
+
|
468
529
|
|
469
530
|
### Added
|
531
|
+
|
470
532
|
- Support for lambdas as default values (nepalez, gzigzigzeo)
|
471
533
|
|
472
|
-
|
534
|
+
|
535
|
+
[Compare v1.1.2...v1.1.3](https://github.com/dry-rb/dry-initializer/compare/v1.1.2...v1.1.3)
|
536
|
+
|
537
|
+
## 1.1.2 2017-02-06
|
538
|
+
|
473
539
|
|
474
540
|
### Changed
|
541
|
+
|
475
542
|
- Remove previously defined methods before redefining them (flash-gordon)
|
476
543
|
|
477
|
-
|
544
|
+
[Compare v1.1.1...v1.1.2](https://github.com/dry-rb/dry-initializer/compare/v1.1.1...v1.1.2)
|
545
|
+
|
546
|
+
## 1.1.1 2017-02-04
|
547
|
+
|
478
548
|
|
479
549
|
### Fixed
|
550
|
+
|
480
551
|
- `@__options__` collects defined options only (nepalez)
|
481
552
|
|
482
|
-
|
553
|
+
|
554
|
+
[Compare v1.1.0...v1.1.1](https://github.com/dry-rb/dry-initializer/compare/v1.1.0...v1.1.1)
|
555
|
+
|
556
|
+
## 1.1.0 2017-01-28
|
557
|
+
|
483
558
|
|
484
559
|
### Added
|
560
|
+
|
485
561
|
- enhancement via `Dry::Initializer::Attribute.dispatchers` registry (nepalez)
|
486
562
|
|
487
563
|
```ruby
|
@@ -500,18 +576,17 @@ and to @gzigzigzeo for persuading me to do this refactoring.
|
|
500
576
|
```
|
501
577
|
|
502
578
|
### Changed
|
503
|
-
- optimize assignments for performance (nepalez)
|
504
579
|
|
505
|
-
|
580
|
+
- optimize assignments for performance (nepalez)
|
506
581
|
|
507
|
-
|
582
|
+
[Compare v1.0.0...v1.1.0](https://github.com/dry-rb/dry-initializer/compare/v1.0.0...v1.1.0)
|
508
583
|
|
509
|
-
|
510
|
-
- [BREAKING] when `param` or `option` was not defined, the corresponding **variable** is set to `Dry::Initializer::UNDEFINED`, but the **reader** (when defined) will return `nil` (nepalez)
|
584
|
+
## 1.0.0 2017-01-22
|
511
585
|
|
512
|
-
|
586
|
+
In this version the code has been rewritten for simplicity
|
513
587
|
|
514
588
|
### Added
|
589
|
+
|
515
590
|
- support for reloading `param` and `option` definitions (nepalez)
|
516
591
|
|
517
592
|
class User
|
@@ -528,7 +603,6 @@ In this version the code has been rewritten for simplicity
|
|
528
603
|
|
529
604
|
# order of the param not changed
|
530
605
|
Admin.new.name # => "Merlin"
|
531
|
-
|
532
606
|
- support for assignment of attributes via several options (nepalez)
|
533
607
|
|
534
608
|
class User
|
@@ -541,244 +615,241 @@ In this version the code has been rewritten for simplicity
|
|
541
615
|
User.new(phone: '1234567890').phone # => '1234567890'
|
542
616
|
User.new(number: '1234567890').phone # => '1234567890'
|
543
617
|
|
544
|
-
|
618
|
+
### Changed
|
545
619
|
|
546
|
-
|
547
|
-
-
|
620
|
+
- [BREAKING] when `param` or `option` was not defined, the corresponding **variable** is set to `Dry::Initializer::UNDEFINED`, but the **reader** (when defined) will return `nil` (nepalez)
|
621
|
+
- `Dry::Initializer` and `Dry::Initializer::Mixin` became aliases (nepalez)
|
548
622
|
|
549
|
-
|
550
|
-
- Refactor the way [#initializer] method is (re)defined (nepalez)
|
551
|
-
|
552
|
-
When you extend class with `Dry::Initializer::Mixin`, the initializer is
|
553
|
-
defined not "inside" the class per se, but inside the included module. The
|
554
|
-
reference to that module is stored as class-level `__initializer_mixin__`.
|
623
|
+
[Compare v0.11.0...v1.0.0](https://github.com/dry-rb/dry-initializer/compare/v0.11.0...v1.0.0)
|
555
624
|
|
556
|
-
|
557
|
-
It is this method to be reloaded every time you envoke a helper
|
558
|
-
`option` or `product`.
|
625
|
+
## 0.11.0 2017-01-02
|
559
626
|
|
560
|
-
When new subclass is inherited, new mixin is added to chain of accessors,
|
561
|
-
but this time it does reload `__initialize__` only, not the `initialize`.
|
562
|
-
That is how you can safely reload initializer using `super`, but at the same
|
563
|
-
time use the whole power of dry-initializer DSL both in parent class and its
|
564
|
-
subclasses.
|
565
627
|
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
- Subclass mixin: ^ `__initialize__`
|
571
|
-
- Subclass: `initialize`
|
628
|
+
### Added
|
629
|
+
|
630
|
+
- Support of reloading `#initializer` with `super` (nepalez)
|
631
|
+
|
572
632
|
|
573
|
-
|
633
|
+
[Compare v0.10.2...v0.11.0](https://github.com/dry-rb/dry-initializer/compare/v0.10.2...v0.11.0)
|
634
|
+
|
635
|
+
## 0.10.2 2016-12-31
|
574
636
|
|
575
|
-
## [0.10.2] [2016-12-31]
|
576
637
|
|
577
638
|
### Added
|
639
|
+
|
578
640
|
- Support of Ruby 2.4 (flas-gordon)
|
579
641
|
|
580
|
-
### Internal
|
581
|
-
- Code clearance for ROM integration (flash-gordon)
|
582
642
|
|
583
|
-
|
643
|
+
[Compare v0.10.1...v0.10.2](https://github.com/dry-rb/dry-initializer/compare/v0.10.1...v0.10.2)
|
644
|
+
|
645
|
+
## 0.10.1 2016-12-27
|
646
|
+
|
584
647
|
|
585
648
|
### Fixed
|
649
|
+
|
586
650
|
- Wrong arity when there were no options and the last param had a default (nolith)
|
587
651
|
|
588
|
-
## [0.10.0] [2016-11-20]
|
589
652
|
|
590
|
-
|
591
|
-
|
653
|
+
[Compare v0.10.0...v0.10.1](https://github.com/dry-rb/dry-initializer/compare/v0.10.0...v0.10.1)
|
654
|
+
|
655
|
+
## 0.10.0 2016-11-20
|
656
|
+
|
592
657
|
|
593
|
-
## [0.9.3] [2016-11-20]
|
594
658
|
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
659
|
+
[Compare v0.9.3...v0.10.0](https://github.com/dry-rb/dry-initializer/compare/v0.9.3...v0.10.0)
|
660
|
+
|
661
|
+
## 0.9.3 2016-11-20
|
662
|
+
|
599
663
|
|
600
664
|
### Fixed
|
665
|
+
|
601
666
|
- Support of weird option names (nepalez)
|
602
667
|
|
603
668
|
```ruby
|
604
669
|
option :"First name", as: :first_name
|
605
670
|
```
|
606
671
|
|
607
|
-
|
672
|
+
|
673
|
+
[Compare v0.9.2...v0.9.3](https://github.com/dry-rb/dry-initializer/compare/v0.9.2...v0.9.3)
|
674
|
+
|
675
|
+
## 0.9.2 2016-11-10
|
676
|
+
|
608
677
|
|
609
678
|
### Fixed
|
679
|
+
|
610
680
|
- Validation of attributes (params and options) (nepalez)
|
611
681
|
|
612
|
-
|
682
|
+
|
683
|
+
[Compare v0.9.1...v0.9.2](https://github.com/dry-rb/dry-initializer/compare/v0.9.1...v0.9.2)
|
684
|
+
|
685
|
+
## 0.9.1 2016-11-06
|
686
|
+
|
613
687
|
|
614
688
|
### Added
|
689
|
+
|
615
690
|
- Support for renaming an option during initialization (nepalez)
|
616
691
|
|
617
692
|
option :name, as: :username # to take :name option and create :username attribute
|
618
693
|
|
619
|
-
|
694
|
+
|
695
|
+
[Compare v0.9.0...v0.9.1](https://github.com/dry-rb/dry-initializer/compare/v0.9.0...v0.9.1)
|
696
|
+
|
697
|
+
## 0.9.0 2016-11-06
|
698
|
+
|
620
699
|
|
621
700
|
### Added
|
701
|
+
|
622
702
|
- The method `#initialize` is defined when a class extended the module (nepalez)
|
623
703
|
|
624
704
|
In previous versions the method was defined only by `param` and `option` calls.
|
625
705
|
|
626
|
-
### Breaking Changes
|
627
|
-
- The initializer accepts any option (but skips unknown) from the very beginning (nepalez)
|
628
706
|
|
629
|
-
|
630
|
-
- Deprecated methods `tolerant_to_unknown_options` and `intolerant_to_unknown_options` (nepalez)
|
707
|
+
[Compare v0.8.1...v0.9.0](https://github.com/dry-rb/dry-initializer/compare/v0.8.1...v0.9.0)
|
631
708
|
|
632
|
-
|
633
|
-
- Refactor scope (`using`) to support methods renaming and aliasing (nepalez)
|
709
|
+
## 0.8.1 2016-11-05
|
634
710
|
|
635
|
-
## [0.8.1] [2016-11-05]
|
636
711
|
|
637
712
|
### Added
|
713
|
+
|
638
714
|
- Support for `dry-struct`ish syntax for constraints (type as a second parameter) (nepalez)
|
639
715
|
|
640
716
|
option :name, Dry::Types['strict.string']
|
641
717
|
|
642
|
-
## [0.8.0] [2016-11-05]
|
643
718
|
|
644
|
-
|
719
|
+
[Compare v0.8.0...v0.8.1](https://github.com/dry-rb/dry-initializer/compare/v0.8.0...v0.8.1)
|
645
720
|
|
646
|
-
|
647
|
-
option :begin
|
721
|
+
## 0.8.0 2016-11-05
|
648
722
|
|
649
|
-
In previous versions this was translated to
|
650
|
-
|
651
|
-
def initialize(end:, begin:)
|
652
|
-
@end = end # BOOM! SyntaxError!
|
653
|
-
@begin = begin # Potential BOOM (unreached)
|
654
|
-
end
|
655
|
-
|
656
|
-
Now the assignment is imlemented like this:
|
657
|
-
|
658
|
-
def initialize(**__options__)
|
659
|
-
@end = __options__.fetch(:end)
|
660
|
-
@begin = __options__.fetch(:begin)
|
661
|
-
end
|
662
|
-
|
663
|
-
As a side effect of the change the initializer becomes tolerant
|
664
|
-
to any unknown option if, and only if some `option` was set explicitly.
|
665
|
-
|
666
|
-
Methods `tolerant_to_unknown_options` and `intolerant_to_unknown_options`
|
667
723
|
are deprecated and will be removed in the next version of the gem.
|
668
724
|
|
669
725
|
### Added
|
726
|
+
|
670
727
|
- support for special options like `option :end`, `option :begin` etc. (nepalez)
|
671
728
|
|
672
729
|
### Changed
|
673
|
-
- switched from key arguments to serialized hash argument in the initializer (nepalez)
|
674
730
|
|
675
|
-
|
676
|
-
- the initializer becomes tolerant to unknown options when any `option` was set,
|
677
|
-
ignoring `intolerant_to_unknown_options` helper.
|
731
|
+
- switched from key arguments to serialized hash argument in the initializer (nepalez)
|
678
732
|
|
679
|
-
-
|
680
|
-
ignoring `tolerant_to_unknown_options` helper.
|
733
|
+
[Compare v0.7.0...v0.8.0](https://github.com/dry-rb/dry-initializer/compare/v0.7.0...v0.8.0)
|
681
734
|
|
682
|
-
|
683
|
-
- `tolerant_to_unknown_options`
|
684
|
-
- `intolerant_to_unknown_options`
|
735
|
+
## 0.7.0 2016-10-11
|
685
736
|
|
686
|
-
## [0.7.0] [2016-10-11]
|
687
737
|
|
688
738
|
### Added
|
739
|
+
|
689
740
|
- Shared settings with `#using` method (nepalez)
|
690
741
|
|
691
|
-
|
742
|
+
|
743
|
+
[Compare v0.6.0...v0.7.0](https://github.com/dry-rb/dry-initializer/compare/v0.6.0...v0.7.0)
|
744
|
+
|
745
|
+
## 0.6.0 2016-10-09
|
746
|
+
|
692
747
|
|
693
748
|
### Added
|
749
|
+
|
694
750
|
- Support for private and protected readers in the `reader:` option (jmgarnier)
|
695
751
|
|
696
|
-
|
752
|
+
|
753
|
+
[Compare v0.5.0...v0.6.0](https://github.com/dry-rb/dry-initializer/compare/v0.5.0...v0.6.0)
|
754
|
+
|
755
|
+
## 0.5.0 2016-08-21
|
756
|
+
|
697
757
|
|
698
758
|
### Added
|
759
|
+
|
699
760
|
- Allow `optional` attribute to be left undefined (nepalez)
|
700
761
|
|
701
|
-
## [0.4.0] [2016-05-28]
|
702
762
|
|
703
|
-
|
704
|
-
|
763
|
+
[Compare v0.4.0...v0.5.0](https://github.com/dry-rb/dry-initializer/compare/v0.4.0...v0.5.0)
|
764
|
+
|
765
|
+
## 0.4.0 2016-05-28
|
766
|
+
|
767
|
+
|
768
|
+
|
769
|
+
[Compare v0.3.3...v0.4.0](https://github.com/dry-rb/dry-initializer/compare/v0.3.3...v0.4.0)
|
770
|
+
|
771
|
+
## 0.3.3 2016-05-28
|
772
|
+
|
773
|
+
|
705
774
|
|
706
|
-
|
775
|
+
[Compare v0.3.2...v0.3.3](https://github.com/dry-rb/dry-initializer/compare/v0.3.2...v0.3.3)
|
707
776
|
|
708
|
-
|
777
|
+
## 0.3.2 2016-05-25
|
709
778
|
|
710
|
-
## [0.3.2] [2016-05-25]
|
711
779
|
|
712
780
|
### Fixed
|
781
|
+
|
713
782
|
- Add explicit requirement for ruby 'set' (rickenharp)
|
714
783
|
|
715
|
-
## [0.3.1] [2016-05-22]
|
716
784
|
|
717
|
-
|
718
|
-
- Support for tolerance to unknown options (nepalez)
|
785
|
+
[Compare v0.3.1...v0.3.2](https://github.com/dry-rb/dry-initializer/compare/v0.3.1...v0.3.2)
|
719
786
|
|
720
|
-
##
|
787
|
+
## 0.3.1 2016-05-22
|
721
788
|
|
722
|
-
Breaks interface for adding new plugins. Register new plugin via:
|
723
789
|
|
724
|
-
|
725
|
-
def self.extended(klass)
|
726
|
-
klass.register_initializer_plugin NewPlugin
|
727
|
-
end
|
728
|
-
```
|
790
|
+
### Added
|
729
791
|
|
730
|
-
|
792
|
+
- Support for tolerance to unknown options (nepalez)
|
731
793
|
|
732
|
-
```
|
733
|
-
def self.extended(klass)
|
734
|
-
klass.initializer_builder.register NewPlugin
|
735
|
-
end
|
736
|
-
```
|
737
794
|
|
738
|
-
|
739
|
-
its method #register doesn't mutate the builder instance.
|
795
|
+
[Compare v0.3.0...v0.3.1](https://github.com/dry-rb/dry-initializer/compare/v0.3.0...v0.3.1)
|
740
796
|
|
741
|
-
|
742
|
-
|
743
|
-
|
797
|
+
## 0.3.0 2016-05-19
|
798
|
+
|
799
|
+
its method #register doesn't mutate the builder instance.
|
744
800
|
|
745
801
|
### Fixed
|
802
|
+
|
746
803
|
- Prevent plugin's registry from polluting superclass (nepalez)
|
747
804
|
|
748
805
|
### Changed
|
806
|
+
|
807
|
+
- Made Mixin##initializer_builder method private (nepalez)
|
808
|
+
- Add Mixin#register_initializer_plugin(plugin) method (nepalez)
|
749
809
|
- Make all instances (Builder and Signature) immutable (nepalez)
|
750
810
|
- Decouple mixin from a builder to prevent pollution (nepalez)
|
751
811
|
- Ensure default value block can use private variables (jeremyf)
|
752
812
|
|
753
|
-
|
813
|
+
[Compare v0.2.1...v0.3.0](https://github.com/dry-rb/dry-initializer/compare/v0.2.1...v0.3.0)
|
814
|
+
|
815
|
+
## 0.2.1 2016-05-19
|
816
|
+
|
754
817
|
|
755
818
|
### Fixed
|
819
|
+
|
756
820
|
- Fix polluting superclass with declarations from subclass (nepalez)
|
757
821
|
|
758
822
|
### Changed
|
823
|
+
|
759
824
|
- Make all instances (Builder and Signature) immutable (nepalez)
|
760
825
|
- Decouple mixin from a builder to prevent pollution (nepalez)
|
761
826
|
- Ensure default value block can use private variables (jeremyf)
|
762
827
|
|
763
|
-
|
828
|
+
[Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-initializer/compare/v0.2.0...v0.2.1)
|
764
829
|
|
765
|
-
|
766
|
-
bugs in "container style". Type constraints were extracted to a plugin
|
767
|
-
that should be added explicitly.
|
768
|
-
|
769
|
-
Small extensions were added to type constraints to support constraint by any
|
770
|
-
object, and apply value coercion via `dry-types`.
|
830
|
+
## 0.2.0 2016-05-16
|
771
831
|
|
772
832
|
Default assignments became slower (while plain type constraint are not)!
|
773
833
|
|
774
|
-
###
|
834
|
+
### Added
|
835
|
+
|
836
|
+
- Support type constraint via every object's case equality (nepalez)
|
837
|
+
|
838
|
+
```ruby
|
839
|
+
option :name, type: /foo/
|
840
|
+
option :name, type: (1...14)
|
841
|
+
```
|
842
|
+
- Support defaults and type constraints for the "container" syntax (nepalez)
|
843
|
+
- Support adding extensions via plugin system (nepalez)
|
844
|
+
|
845
|
+
### Changed
|
846
|
+
|
775
847
|
- Make dry-types constraint to coerce variables (nepalez)
|
776
848
|
|
777
849
|
```ruby
|
778
850
|
# This will coerce `name: :foo` to `"foo"`
|
779
851
|
option :name, type: Dry::Types::Coercible::String
|
780
852
|
```
|
781
|
-
|
782
853
|
- Stop supporing proc type constraint (nepalez)
|
783
854
|
|
784
855
|
```ruby
|
@@ -798,86 +869,32 @@ Default assignments became slower (while plain type constraint are not)!
|
|
798
869
|
end
|
799
870
|
```
|
800
871
|
|
801
|
-
|
802
|
-
- Support type constraint via every object's case equality (nepalez)
|
872
|
+
[Compare v0.1.1...v0.2.0](https://github.com/dry-rb/dry-initializer/compare/v0.1.1...v0.2.0)
|
803
873
|
|
804
|
-
|
805
|
-
option :name, type: /foo/
|
806
|
-
option :name, type: (1...14)
|
807
|
-
```
|
874
|
+
## 0.1.1 2016-04-28
|
808
875
|
|
809
|
-
- Support defaults and type constraints for the "container" syntax (nepalez)
|
810
|
-
- Support adding extensions via plugin system (nepalez)
|
811
876
|
|
812
|
-
###
|
813
|
-
|
877
|
+
### Added
|
878
|
+
|
879
|
+
- `include Dry::Initializer.define -> do ... end` syntax (flash-gordon)
|
814
880
|
|
815
|
-
The previous implementation required defaults and types to be stored in the class method `.initializer_builder`.
|
816
|
-
That made "container" syntax to support neither defaults nor types.
|
817
881
|
|
818
|
-
|
819
|
-
(like default assignments, coercions, dry-type constraints etc.) cannot be implemented in this way.
|
820
|
-
They are made inside `##__after_initialize__` callback, that is biult via `default_method(&block)`
|
821
|
-
using instance evals.
|
882
|
+
[Compare v0.1.0...v0.1.1](https://github.com/dry-rb/dry-initializer/compare/v0.1.0...v0.1.1)
|
822
883
|
|
823
|
-
##
|
884
|
+
## 0.1.0 2016-04-26
|
885
|
+
|
886
|
+
Backward compatibility is broken.
|
824
887
|
|
825
888
|
### Added
|
826
|
-
- `include Dry::Initializer.define -> do ... end` syntax (flash-gordon)
|
827
889
|
|
828
|
-
|
890
|
+
- Use `include Dry::Initializer.define(&block)` as an alternative to extending the class (nepalez)
|
829
891
|
|
830
|
-
|
831
|
-
Backward compatibility is broken.
|
892
|
+
### Changed
|
832
893
|
|
833
|
-
### Changed (backward-incompatible changes)
|
834
894
|
- Use `extend Dry::Initializer::Mixin` instead of `extend Dry::Initializer` (nepalez)
|
835
895
|
|
836
|
-
|
837
|
-
- Use `include Dry::Initializer.define(&block)` as an alternative to extending the class (nepalez)
|
896
|
+
[Compare v0.0.1...v0.1.0](https://github.com/dry-rb/dry-initializer/compare/v0.0.1...v0.1.0)
|
838
897
|
|
839
|
-
##
|
898
|
+
## 0.0.1 2016-04-09
|
840
899
|
|
841
900
|
First public release
|
842
|
-
|
843
|
-
[0.1.0]: https://github.com/dry-rb/dry-initializer/compare/v0.0.1...v0.1.0
|
844
|
-
[0.1.1]: https://github.com/dry-rb/dry-initializer/compare/v0.1.0...v0.1.1
|
845
|
-
[0.2.0]: https://github.com/dry-rb/dry-initializer/compare/v0.1.1...v0.2.0
|
846
|
-
[0.2.1]: https://github.com/dry-rb/dry-initializer/compare/v0.2.0...v0.2.1
|
847
|
-
[0.2.1]: https://github.com/dry-rb/dry-initializer/compare/v0.2.0...v0.2.1
|
848
|
-
[0.3.0]: https://github.com/dry-rb/dry-initializer/compare/v0.2.1...v0.3.0
|
849
|
-
[0.3.1]: https://github.com/dry-rb/dry-initializer/compare/v0.3.0...v0.3.1
|
850
|
-
[0.3.2]: https://github.com/dry-rb/dry-initializer/compare/v0.3.1...v0.3.2
|
851
|
-
[0.3.3]: https://github.com/dry-rb/dry-initializer/compare/v0.3.2...v0.3.3
|
852
|
-
[0.4.0]: https://github.com/dry-rb/dry-initializer/compare/v0.3.3...v0.4.0
|
853
|
-
[0.5.0]: https://github.com/dry-rb/dry-initializer/compare/v0.4.0...v0.5.0
|
854
|
-
[0.6.0]: https://github.com/dry-rb/dry-initializer/compare/v0.5.0...v0.6.0
|
855
|
-
[0.7.0]: https://github.com/dry-rb/dry-initializer/compare/v0.6.0...v0.7.0
|
856
|
-
[0.8.0]: https://github.com/dry-rb/dry-initializer/compare/v0.7.0...v0.8.0
|
857
|
-
[0.8.1]: https://github.com/dry-rb/dry-initializer/compare/v0.8.0...v0.8.1
|
858
|
-
[0.9.0]: https://github.com/dry-rb/dry-initializer/compare/v0.8.1...v0.9.0
|
859
|
-
[0.9.1]: https://github.com/dry-rb/dry-initializer/compare/v0.9.0...v0.9.1
|
860
|
-
[0.9.2]: https://github.com/dry-rb/dry-initializer/compare/v0.9.1...v0.9.2
|
861
|
-
[0.9.3]: https://github.com/dry-rb/dry-initializer/compare/v0.9.2...v0.9.3
|
862
|
-
[0.10.0]: https://github.com/dry-rb/dry-initializer/compare/v0.9.3...v0.10.0
|
863
|
-
[0.10.1]: https://github.com/dry-rb/dry-initializer/compare/v0.10.0...v0.10.1
|
864
|
-
[0.10.2]: https://github.com/dry-rb/dry-initializer/compare/v0.10.1...v0.10.2
|
865
|
-
[0.11.0]: https://github.com/dry-rb/dry-initializer/compare/v0.10.2...v0.11.0
|
866
|
-
[1.0.0]: https://github.com/dry-rb/dry-initializer/compare/v0.11.0...v1.0.0
|
867
|
-
[1.1.0]: https://github.com/dry-rb/dry-initializer/compare/v1.0.0...v1.1.0
|
868
|
-
[1.1.1]: https://github.com/dry-rb/dry-initializer/compare/v1.1.0...v1.1.1
|
869
|
-
[1.1.2]: https://github.com/dry-rb/dry-initializer/compare/v1.1.1...v1.1.2
|
870
|
-
[1.1.3]: https://github.com/dry-rb/dry-initializer/compare/v1.1.2...v1.1.3
|
871
|
-
[1.2.0]: https://github.com/dry-rb/dry-initializer/compare/v1.1.3...v1.2.0
|
872
|
-
[1.3.0]: https://github.com/dry-rb/dry-initializer/compare/v1.2.0...v1.3.0
|
873
|
-
[1.4.0]: https://github.com/dry-rb/dry-initializer/compare/v1.3.0...v1.4.0
|
874
|
-
[1.4.1]: https://github.com/dry-rb/dry-initializer/compare/v1.4.0...v1.4.1
|
875
|
-
[2.0.0]: https://github.com/dry-rb/dry-initializer/compare/v1.4.1...v2.0.0
|
876
|
-
[2.1.0]: https://github.com/dry-rb/dry-initializer/compare/v2.0.0...v2.1.0
|
877
|
-
[2.2.0]: https://github.com/dry-rb/dry-initializer/compare/v2.1.0...v2.2.0
|
878
|
-
[2.3.0]: https://github.com/dry-rb/dry-initializer/compare/v2.2.0...v2.3.0
|
879
|
-
[2.4.0]: https://github.com/dry-rb/dry-initializer/compare/v2.3.0...v2.4.0
|
880
|
-
[2.6.0]: https://github.com/dry-rb/dry-initializer/compare/v2.4.0...v2.5.0
|
881
|
-
[2.6.0]: https://github.com/dry-rb/dry-initializer/compare/v2.5.0...v2.6.0
|
882
|
-
[3.0.0]: https://github.com/dry-rb/dry-initializer/compare/v2.5.0...v3.0.0
|
883
|
-
[3.0.1]: https://github.com/dry-rb/dry-initializer/compare/v3.0.0...v3.0.1
|