dry-initializer 2.5.0 → 3.0.4

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