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