dry-initializer 1.4.1 → 2.0.0

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 (59) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +8 -8
  3. data/.travis.yml +0 -3
  4. data/CHANGELOG.md +339 -196
  5. data/LICENSE.txt +1 -1
  6. data/README.md +3 -3
  7. data/Rakefile +2 -47
  8. data/benchmarks/{several_defaults.rb → compare_several_defaults.rb} +4 -4
  9. data/benchmarks/{without_options.rb → plain_options.rb} +20 -9
  10. data/benchmarks/{params.rb → plain_params.rb} +20 -9
  11. data/benchmarks/{with_types.rb → with_coercion.rb} +20 -9
  12. data/benchmarks/with_defaults.rb +19 -8
  13. data/benchmarks/{with_types_and_defaults.rb → with_defaults_and_coercion.rb} +21 -10
  14. data/dry-initializer.gemspec +3 -3
  15. data/lib/dry/initializer/builders/attribute.rb +76 -0
  16. data/lib/dry/initializer/builders/initializer.rb +61 -0
  17. data/lib/dry/initializer/builders/reader.rb +50 -0
  18. data/lib/dry/initializer/builders/signature.rb +32 -0
  19. data/lib/dry/initializer/builders.rb +7 -0
  20. data/lib/dry/initializer/config.rb +161 -0
  21. data/lib/dry/initializer/definition.rb +93 -0
  22. data/lib/dry/initializer/dsl.rb +43 -0
  23. data/lib/dry/initializer/mixin/local.rb +19 -0
  24. data/lib/dry/initializer/mixin/root.rb +10 -0
  25. data/lib/dry/initializer/mixin.rb +15 -0
  26. data/lib/dry/initializer.rb +45 -41
  27. data/lib/tasks/benchmark.rake +41 -0
  28. data/lib/tasks/profile.rake +78 -0
  29. data/spec/{options_var_spec.rb → attributes_spec.rb} +9 -9
  30. data/spec/custom_initializer_spec.rb +1 -1
  31. data/spec/default_values_spec.rb +6 -6
  32. data/spec/definition_spec.rb +21 -14
  33. data/spec/invalid_default_spec.rb +2 -2
  34. data/spec/missed_default_spec.rb +2 -2
  35. data/spec/optional_spec.rb +2 -2
  36. data/spec/options_tolerance_spec.rb +1 -1
  37. data/spec/public_attributes_utility_spec.rb +22 -0
  38. data/spec/reader_spec.rb +11 -11
  39. data/spec/repetitive_definitions_spec.rb +5 -5
  40. data/spec/several_assignments_spec.rb +1 -1
  41. data/spec/spec_helper.rb +5 -0
  42. data/spec/subclassing_spec.rb +7 -3
  43. data/spec/type_argument_spec.rb +1 -1
  44. data/spec/type_constraint_spec.rb +2 -2
  45. data/spec/value_coercion_via_dry_types_spec.rb +1 -1
  46. metadata +27 -27
  47. data/benchmarks/options.rb +0 -54
  48. data/benchmarks/params_vs_options.rb +0 -35
  49. data/benchmarks/profiler.rb +0 -28
  50. data/lib/dry/initializer/attribute.rb +0 -123
  51. data/lib/dry/initializer/builder.rb +0 -127
  52. data/lib/dry/initializer/class_dsl.rb +0 -37
  53. data/lib/dry/initializer/exceptions/default_value_error.rb +0 -8
  54. data/lib/dry/initializer/exceptions/params_order_error.rb +0 -8
  55. data/lib/dry/initializer/exceptions/type_constraint_error.rb +0 -7
  56. data/lib/dry/initializer/instance_dsl.rb +0 -15
  57. data/lib/dry/initializer/option.rb +0 -61
  58. data/lib/dry/initializer/param.rb +0 -52
  59. data/spec/gem_enhancement_spec.rb +0 -18
data/CHANGELOG.md CHANGED
@@ -1,24 +1,230 @@
1
- ## v1.4.1 2017-04-05
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
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
+
8
+ ## [2.0.0] To be released ASAP
9
+
10
+ The gem has been rewritten under the hood keeping its documented
11
+ interface about the same (see "Deleted" section below for the only
12
+ backward-incompatible change).
13
+
14
+ The main achievement of this version is fixing an edge case where
15
+ change in params/options of superclass wasn't reflected in its
16
+ previously declared subclasses.
17
+
18
+ Thanks to @solnic for the idea of class-level container,
19
+ and to @gzigzigzeo for persuading me to do this refactoring.
20
+
21
+ ### Deleted
22
+ - Undocumented variable `@__option__` which was the main reason for refactoring
23
+ (gzigzigzeo, nepalez).
24
+
25
+ ### Added
26
+ - Class method `.dry_initializer` -- a container for `.params` and `.options`
27
+ `.definitions` along with the `.null` setting (either `nil` or `UNDEFINED`)
28
+ used for unassigned values (nepalez)
29
+
30
+ - `.dry_initializer.attributes` method takes an instance of the same class
31
+ and returns the hash of assigned options. This provide the same
32
+ functionality as previously used instance variable `@__options__` (nepalez)
33
+
34
+ ```ruby
35
+ object.class.dry_initializer.attributes(object)
36
+ ```
37
+
38
+ When you use "Dry::Initializer.define -> { ... }" syntax,
39
+ the class method `.dry_initializer` is not defined. To access attributes
40
+ you should use private instance method `#__dry_initializer_config__` instead:
41
+
42
+ ```ruby
43
+ object.send(:__dry_initializer_config__).attributes(object)
44
+ ```
45
+
46
+ Both methods `.dry_initializer` and `#__dry_initializer_config__` refer
47
+ to the same object.
48
+
49
+ - `.dry_initializer.public_attributes`. This method works differently:
50
+ it looks through (possibly reloaded) readers instead of variables
51
+ (gzigzigzeo, nepalez)
52
+
53
+ ```ruby
54
+ object.class.dry_initializer.public_attributes(object)
55
+ ```
56
+
57
+ You can use the same trick as above mutatis mutandis.
58
+
59
+ ### Fixed
60
+ - Definition order dependency bug (nepalez)
61
+
62
+ I've found out that if you provided a subclass and then changed params
63
+ or options of its superclass, these changes woudn't be reflected in
64
+ subclasses until you change any of it params/options as well.
65
+
66
+ Now this bug is fixed: every time you call `param` or `option` at
67
+ any class, the gem scans through all its descendants to the very bottom
68
+ of the tree, and reloads their defintitions.
69
+
70
+ Being done in load time, the rebuilt makes no effect on runtime performance.
71
+
72
+ - Possible misbehavior when you define param and option with the same name (nepalez)
73
+
74
+ Doing this will provide `option :name` only, not both:
75
+
76
+ ```ruby
77
+ param :name
78
+ option :name
79
+ ```
80
+
81
+ - Attempt to redefine param/option of superclass with option/param in
82
+ its subclass will cause an exception because it would break
83
+ Liskov substitute principle with unexpected behaviour (nepalez)
84
+
85
+ No, you can do neither these definitions, nor vice versa:
86
+
87
+ ```ruby
88
+ class Foo
89
+ extend Dry::Intitializer
90
+ param :name
91
+ end
92
+
93
+ class Bar < Foo
94
+ option :name
95
+ end
96
+ ```
97
+
98
+ - When you reloading previously defined param of superclass, the gem
99
+ will check all its descendands for whether all required positional params
100
+ goes before optional ones (nepalez)
101
+
102
+ ```ruby
103
+ class Foo
104
+ param :name
105
+ # Foo: def initializer(name)
106
+ end
107
+
108
+ class Bar
109
+ param :email
110
+ # Bar: def initializer(name, email)
111
+ end
112
+
113
+ class Foo
114
+ # This raises SyntaxError because in Bar this would cause wrong definition
115
+ # Foo: def initializer(name = nil)
116
+ # Bar: def initializer(name = nil, email)
117
+ param :name, optional: true
118
+ end
119
+ ```
120
+
121
+ ### Changed
122
+ - Under the hood I've separated param/option settings declaration (a container
123
+ with param/option settings) from code builders for initializer and readers
124
+ (nepalez)
125
+
126
+ You can check both the code for the `__initializer__`:
127
+
128
+ ```ruby
129
+ class Foo
130
+ extend Dry::Initializer
131
+ # ...
132
+ end
133
+
134
+ Foo.dry_initializer.code
135
+ ```
136
+
137
+ and readers:
138
+
139
+ ```ruby
140
+ Foo.dry_initializer.params.map(&:code)
141
+ Foo.dry_initializer.options.map(&:code)
142
+
143
+ # or
144
+
145
+ Foo.dry_initializer.definitions.values.map(&:code)
146
+ ```
147
+
148
+ You can also check settings for every param and option using methods
149
+ `dry_initializer.params`, `dry_initializer.options` (lists), or
150
+ `dry_initializer.definitions` (hash).
151
+
152
+ You can check null value via `.dry_initializer.null` which is different
153
+ for `Dry::Initializer` and `Dry::Initializer[undefined: false]` modules.
154
+
155
+ - Optimized the code for `__initializer__`-s (the method where all magics occurs)
156
+ (nepalez)
157
+
158
+ Benchmarks remained about the same:
159
+
160
+ ```shell
161
+ rake benchmark
162
+ ```
163
+
164
+ ```
165
+ Benchmark for instantiation with plain params
166
+ value_struct: 4317196.9 i/s
167
+ plain Ruby: 4129803.9 i/s - 1.05x slower
168
+ dry-initializer: 1710702.1 i/s - 2.52x slower
169
+ concord: 1372630.4 i/s - 3.15x slower
170
+ values: 601651.8 i/s - 7.18x slower
171
+ attr_extras: 535599.5 i/s - 8.06x slower
172
+ ```
173
+
174
+ ```
175
+ Benchmark for instantiation with plain options
176
+ plain Ruby: 1769174.1 i/s
177
+ dry-initializer: 636634.1 i/s - 2.78x slower
178
+ kwattr: 423296.5 i/s - 4.18x slower
179
+ anima: 399415.0 i/s - 4.43x slower
180
+ ```
181
+
182
+ ```
183
+ Benchmark for instantiation with coercion
184
+ plain Ruby: 1565501.0 i/s
185
+ fast_attributes: 569952.9 i/s - 2.75x slower
186
+ dry-initializer: 461122.1 i/s - 3.39x slower
187
+ virtus: 138074.8 i/s - 11.34x slower
188
+ ```
189
+
190
+ ```
191
+ Benchmark for instantiation with default values
192
+ plain Ruby: 3402455.4 i/s
193
+ kwattr: 586206.5 i/s - 5.80x slower
194
+ dry-initializer: 528482.2 i/s - 6.44x slower
195
+ active_attr: 298697.7 i/s - 11.39x slower
196
+ ```
197
+
198
+ ```
199
+ Benchmark for instantiation with type constraints and default values
200
+ plain Ruby: 2881696.1 i/s
201
+ dry-initializer: 470815.1 i/s - 6.12x slower
202
+ virtus: 180272.6 i/s - 15.99x slower
203
+ ```
204
+
205
+ ## [1.4.1] [2017-04-05]
2
206
 
3
207
  ### Fixed
4
208
  - Warning about redefined `#initialize` in case the method reloaded in a klass
5
209
  that extends the module (nepalez, sergey-chechaev)
6
210
 
7
- ### Internals
211
+ ### Changed
8
212
  - Rename `Dry::Initializer::DSL` -> `Dry::Initializer::ClassDSL` (nepalez)
9
213
  - Add `Dry::Initializer::InstanceDSL` (nepalez)
10
214
 
11
- [Compare v1.4.0...v1.4.1](https://github.com/dry-rb/dry-initializer/compare/v1.4.0...v1.4.1)
215
+ ### Deprecated
216
+ - `Dry::Initializer::Mixin`. In latest version this was an alias for
217
+ `Dry::Initializer` that kept for backward compatibility for early versions of the gem.
218
+
219
+ This story will come to the end in `v2.1.0`.
12
220
 
13
- ## v1.4.0 2017-03-08
221
+ ## [1.4.0] [2017-03-08]
14
222
 
15
223
  ### Changed (backward-incompatible)
16
224
  - The `@__options__` hash now collects all assigned attributes,
17
225
  collected via `#option` (as before), and `#param` (nepalez)
18
226
 
19
- [Compare v1.3.0...v1.4.0](https://github.com/dry-rb/dry-initializer/compare/v1.3.0...v1.4.0)
20
-
21
- ## v1.3.0 2017-03-05
227
+ ## [1.3.0] [2017-03-05]
22
228
 
23
229
  ### Added
24
230
  - No-undefined configuration of the initializer (nepalez, flash-gordon)
@@ -42,42 +248,32 @@
42
248
  Foo.new.instance_variable_get(:@qux) # => Dry::Initializer::UNDEFINED
43
249
  Bar.new.instance_variable_get(:@qux) # => nil
44
250
 
45
- ### Internals
251
+ ### Changed
46
252
  - Fixed method definitions for performance at the load time (nepalez, flash-gordon)
47
253
 
48
- [Compare v1.2.0...v1.3.0](https://github.com/dry-rb/dry-initializer/compare/v1.2.0...v1.3.0)
49
-
50
- ## v1.2.0 2017-03-05
254
+ ## [1.2.0] [2017-03-05]
51
255
 
52
256
  ### Fixed
53
257
  - The `@__options__` variable collects renamed options after default values and coercions were applied (nepalez)
54
258
 
55
- [Compare v1.1.3...v1.2.0](https://github.com/dry-rb/dry-initializer/compare/v1.1.3...v1.2.0)
56
-
57
- ## v1.1.3 2017-03-01
259
+ ## [1.1.3] [2017-03-01]
58
260
 
59
261
  ### Added
60
262
  - Support for lambdas as default values (nepalez, gzigzigzeo)
61
263
 
62
- [Compare v1.1.2...v1.1.3](https://github.com/dry-rb/dry-initializer/compare/v1.1.2...v1.1.3)
63
-
64
- ## v1.1.2 2017-02-06
264
+ ## [1.1.2] [2017-02-06]
65
265
 
66
- ### Internals
266
+ ### Changed
67
267
  - Remove previously defined methods before redefining them (flash-gordon)
68
268
 
69
- [Compare v1.1.1...v1.1.2](https://github.com/dry-rb/dry-initializer/compare/v1.1.1...v1.1.2)
269
+ ## [1.1.1] [2017-02-04]
70
270
 
71
- ## v1.1.1 2017-02-04
72
-
73
- ### Bugs Fixed
271
+ ### Fixed
74
272
  - `@__options__` collects defined options only (nepalez)
75
273
 
76
- [Compare v1.1.0...v1.1.1](https://github.com/dry-rb/dry-initializer/compare/v1.1.0...v1.1.1)
274
+ ## [1.1.0] [2017-01-28]
77
275
 
78
- ## v1.1.0 2017-01-28
79
-
80
- ### Added:
276
+ ### Added
81
277
  - enhancement via `Dry::Initializer::Attribute.dispatchers` registry (nepalez)
82
278
 
83
279
  # Register dispatcher for `:string` option
@@ -93,19 +289,19 @@
93
289
 
94
290
  User.new(:Andy).name # => "Andy"
95
291
 
96
- ### Internals:
292
+ ### Changed
97
293
  - optimize assignments for performance (nepalez)
98
294
 
99
- [Compare v1.0.0...v1.1.0](https://github.com/dry-rb/dry-initializer/compare/v1.0.0...v1.1.0)
100
-
101
- ## v1.0.0 2017-01-22
295
+ ## [1.0.0] [2017-01-22]
102
296
 
103
297
  In this version the code has been rewritten for simplicity
104
298
 
105
- ### BREAKING CHANGES
106
- - 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)
299
+ ### Changed
300
+ - [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)
301
+
302
+ - `Dry::Initializer` and `Dry::Initializer::Mixin` became aliases (nepalez)
107
303
 
108
- ### Added:
304
+ ### Added
109
305
  - support for reloading `param` and `option` definitions (nepalez)
110
306
 
111
307
  class User
@@ -135,20 +331,13 @@ In this version the code has been rewritten for simplicity
135
331
  User.new(phone: '1234567890').phone # => '1234567890'
136
332
  User.new(number: '1234567890').phone # => '1234567890'
137
333
 
138
- ### Internals
139
- - `Dry::Initializer` and `Dry::Initializer::Mixin` became aliases (nepalez)
140
-
141
- [Compare v0.11.0...v1.0.0](https://github.com/dry-rb/dry-initializer/compare/v0.11.0...v1.0.0)
142
-
143
- ## v0.11.0 2017-01-02
334
+ ## [0.11.0] [2017-01-02]
144
335
 
145
336
  ### Added
146
-
147
- * Support of reloading `#initializer` with `super` (nepalez)
337
+ - Support of reloading `#initializer` with `super` (nepalez)
148
338
 
149
339
  ### Internal
150
-
151
- * Refactor the way [#initializer] method is (re)defined (nepalez)
340
+ - Refactor the way [#initializer] method is (re)defined (nepalez)
152
341
 
153
342
  When you extend class with `Dry::Initializer::Mixin`, the initializer is
154
343
  defined not "inside" the class per se, but inside the included module. The
@@ -173,105 +362,74 @@ In this version the code has been rewritten for simplicity
173
362
 
174
363
  See specification `spec/custom_initializer_spec.rb` to see how this works.
175
364
 
176
- [Compare v0.10.2...v0.11.0](https://github.com/dry-rb/dry-initializer/compare/v0.10.2...v0.11.0)
177
-
178
- ## v0.10.2 2016-12-31
365
+ ## [0.10.2] [2016-12-31]
179
366
 
180
367
  ### Added
181
-
182
- * Support of Ruby 2.4 (flas-gordon)
368
+ - Support of Ruby 2.4 (flas-gordon)
183
369
 
184
370
  ### Internal
371
+ - Code clearance for ROM integration (flash-gordon)
185
372
 
186
- * Code clearance for ROM integration (flash-gordon)
187
-
188
- [Compare v0.10.1...v0.10.2](https://github.com/dry-rb/dry-initializer/compare/v0.10.1...v0.10.2)
189
-
190
- ## v0.10.1 2016-12-27
373
+ ## [0.10.1] [2016-12-27]
191
374
 
192
375
  ### Fixed
376
+ - Wrong arity when there were no options and the last param had a default (nolith)
193
377
 
194
- * Wrong arity when there were no options and the last param had a default (nolith)
195
-
196
- [Compare v0.10.0...v0.10.1](https://github.com/dry-rb/dry-initializer/compare/v0.10.0...v0.10.1)
197
-
198
- ## v0.10.0 2016-11-20
378
+ ## [0.10.0] [2016-11-20]
199
379
 
200
380
  ### Deleted (BREAKING CHANGE!)
381
+ - Deprecated method DSL#using (nepalez)
201
382
 
202
- * Deprecated method DSL#using (nepalez)
203
-
204
- [Compare v0.9.3...v0.10.0](https://github.com/dry-rb/dry-initializer/compare/v0.9.3...v0.10.0)
205
-
206
- ## v0.9.3 2016-11-20
383
+ ## [0.9.3] [2016-11-20]
207
384
 
208
385
  ### Deprecated
209
-
210
- * After discussion in [PR #17](https://github.com/dry-rb/dry-initializer/pull/17)
386
+ - After discussion in [PR #17]: https://github.com/dry-rb/dry-initializer/pull/17)
211
387
  (many thanks to @sahal2080 and @hrom512 for starting that issue and PR),
212
388
  the method `using` is deprecated and will be removed from v0.10.0 (nepalez)
213
389
 
214
390
  ### Fixed
215
-
216
- * Support of weird option names (nepalez)
391
+ - Support of weird option names (nepalez)
217
392
 
218
393
  ```ruby
219
394
  option :"First name", as: :first_name
220
395
  ```
221
396
 
222
- [Compare v0.9.2...v0.9.3](https://github.com/dry-rb/dry-initializer/compare/v0.9.2...v0.9.3)
223
-
224
- ## v0.9.2 2016-11-10
397
+ ## [0.9.2] [2016-11-10]
225
398
 
226
399
  ### Fixed
400
+ - Validation of attributes (params and options) (nepalez)
227
401
 
228
- * Validation of attributes (params and options) (nepalez)
229
-
230
- [Compare v0.9.1...v0.9.2](https://github.com/dry-rb/dry-initializer/compare/v0.9.1...v0.9.2)
231
-
232
- ## v0.9.1 2016-11-06
402
+ ## [0.9.1] [2016-11-06]
233
403
 
234
404
  ### Added
235
-
236
- * Support for renaming an option during initialization (nepalez)
405
+ - Support for renaming an option during initialization (nepalez)
237
406
 
238
407
  option :name, as: :username # to take :name option and create :username attribute
239
408
 
240
- [Compare v0.9.0...v0.9.1](https://github.com/dry-rb/dry-initializer/compare/v0.9.0...v0.9.1)
241
-
242
- ## v0.9.0 2016-11-06
409
+ ## [0.9.0] [2016-11-06]
243
410
 
244
411
  ### Added
245
-
246
- * The method `#initialize` is defined when a class extended the module (nepalez)
412
+ - The method `#initialize` is defined when a class extended the module (nepalez)
247
413
 
248
414
  In previous versions the method was defined only by `param` and `option` calls.
249
415
 
250
416
  ### Breaking Changes
251
-
252
- * The initializer accepts any option (but skips unknown) from the very beginning (nepalez)
417
+ - The initializer accepts any option (but skips unknown) from the very beginning (nepalez)
253
418
 
254
419
  ### Deleted
255
-
256
- * Deprecated methods `tolerant_to_unknown_options` and `intolerant_to_unknown_options` (nepalez)
420
+ - Deprecated methods `tolerant_to_unknown_options` and `intolerant_to_unknown_options` (nepalez)
257
421
 
258
422
  ### Internal
423
+ - Refactor scope (`using`) to support methods renaming and aliasing (nepalez)
259
424
 
260
- * Refactor scope (`using`) to support methods renaming and aliasing (nepalez)
261
-
262
- [Compare v0.8.1...v0.9.0](https://github.com/dry-rb/dry-initializer/compare/v0.8.1...v0.9.0)
263
-
264
- ## v0.8.1 2016-11-05
425
+ ## [0.8.1] [2016-11-05]
265
426
 
266
427
  ### Added
267
-
268
- * Support for `dry-struct`ish syntax for constraints (type as a second parameter) (nepalez)
428
+ - Support for `dry-struct`ish syntax for constraints (type as a second parameter) (nepalez)
269
429
 
270
430
  option :name, Dry::Types['strict.string']
271
431
 
272
- [Compare v0.8.0...v0.8.1](https://github.com/dry-rb/dry-initializer/compare/v0.8.0...v0.8.1)
273
-
274
- ## v0.8.0 2016-11-05
432
+ ## [0.8.0] [2016-11-05]
275
433
 
276
434
  In this version we switched from key arguments to ** to support special keys:
277
435
 
@@ -299,83 +457,57 @@ Methods `tolerant_to_unknown_options` and `intolerant_to_unknown_options`
299
457
  are deprecated and will be removed in the next version of the gem.
300
458
 
301
459
  ### Added
460
+ - support for special options like `option :end`, `option :begin` etc. (nepalez)
302
461
 
303
- * support for special options like `option :end`, `option :begin` etc. (nepalez)
304
-
305
- ### Internals
306
-
307
- * switched from key arguments to serialized hash argument in the initializer (nepalez)
462
+ ### Changed
463
+ - switched from key arguments to serialized hash argument in the initializer (nepalez)
308
464
 
309
465
  ### Breaking Changes
310
-
311
- * the initializer becomes tolerant to unknown options when any `option` was set,
466
+ - the initializer becomes tolerant to unknown options when any `option` was set,
312
467
  ignoring `intolerant_to_unknown_options` helper.
313
468
 
314
- * the initializer becomes intolerant to options when no `option` was set,
469
+ - the initializer becomes intolerant to options when no `option` was set,
315
470
  ignoring `tolerant_to_unknown_options` helper.
316
471
 
317
472
  ### Deprecated
473
+ - `tolerant_to_unknown_options`
474
+ - `intolerant_to_unknown_options`
318
475
 
319
- * `tolerant_to_unknown_options`
320
- * `intolerant_to_unknown_options`
321
-
322
- [Compare v0.7.0...v0.8.0](https://github.com/dry-rb/dry-initializer/compare/v0.7.0...v0.8.0)
323
-
324
- ## v0.7.0 2016-10-11
476
+ ## [0.7.0] [2016-10-11]
325
477
 
326
478
  ### Added
479
+ - Shared settings with `#using` method (nepalez)
327
480
 
328
- * Shared settings with `#using` method (nepalez)
329
-
330
- [Compare v0.6.0...v0.7.0](https://github.com/dry-rb/dry-initializer/compare/v0.6.0...v0.7.0)
331
-
332
- ## v0.6.0 2016-10-09
481
+ ## [0.6.0] [2016-10-09]
333
482
 
334
483
  ### Added
484
+ - Support for private and protected readers in the `reader:` option (jmgarnier)
335
485
 
336
- * Support for private and protected readers in the `reader:` option (jmgarnier)
337
-
338
- [Compare v0.5.0...v0.6.0](https://github.com/dry-rb/dry-initializer/compare/v0.5.0...v0.6.0)
339
-
340
- ## v0.5.0 2016-08-21
486
+ ## [0.5.0] [2016-08-21]
341
487
 
342
488
  ### Added
489
+ - Allow `optional` attribute to be left undefined (nepalez)
343
490
 
344
- * Allow `optional` attribute to be left undefined (nepalez)
345
-
346
- [Compare v0.4.0...v0.5.0](https://github.com/dry-rb/dry-initializer/compare/v0.4.0...v0.5.0)
347
-
348
- ## v0.4.0 2016-05-28
491
+ ## [0.4.0] [2016-05-28]
349
492
 
350
493
  ### Deleted (backward-incompatible changes)
494
+ - Support of modules and case equality as type constraints (nepalez)
351
495
 
352
- * Support of modules and case equality as type constraints (nepalez)
353
-
354
- [Compare v0.3.3...v0.4.0](https://github.com/dry-rb/dry-initializer/compare/v0.3.3...v0.4.0)
355
-
356
- ## v0.3.3 2016-05-28
357
-
358
- * Add deprecation warnings about modules and case equality as type constraints (nepalez)
496
+ ## [0.3.3] [2016-05-28]
359
497
 
360
- [Compare v0.3.2...v0.3.3](https://github.com/dry-rb/dry-initializer/compare/v0.3.2...v0.3.3)
498
+ - Add deprecation warnings about modules and case equality as type constraints (nepalez)
361
499
 
362
- ## v0.3.2 2016-05-25
500
+ ## [0.3.2] [2016-05-25]
363
501
 
364
- ### Bugs Fixed
365
-
366
- * Add explicit requirement for ruby 'set' (rickenharp)
367
-
368
- [Compare v0.3.1...v0.3.2](https://github.com/dry-rb/dry-initializer/compare/v0.3.1...v0.3.2)
502
+ ### Fixed
503
+ - Add explicit requirement for ruby 'set' (rickenharp)
369
504
 
370
- ## v0.3.1 2016-05-22
505
+ ## [0.3.1] [2016-05-22]
371
506
 
372
507
  ### Added
508
+ - Support for tolerance to unknown options (nepalez)
373
509
 
374
- * Support for tolerance to unknown options (nepalez)
375
-
376
- [Compare v0.3.0...v0.3.1](https://github.com/dry-rb/dry-initializer/compare/v0.3.0...v0.3.1)
377
-
378
- ## v0.3.0 2016-05-19
510
+ ## [0.3.0] [2016-05-19]
379
511
 
380
512
  Breaks interface for adding new plugins. Register new plugin via:
381
513
 
@@ -397,39 +529,28 @@ While the private method ##initializer_builder is still accessible
397
529
  its method #register doesn't mutate the builder instance.
398
530
 
399
531
  ### Changed (backward-incompatible changes)
532
+ - Made Mixin##initializer_builder method private (nepalez)
533
+ - Add Mixin#register_initializer_plugin(plugin) method (nepalez)
400
534
 
401
- * Made Mixin##initializer_builder method private (nepalez)
402
- * Add Mixin#register_initializer_plugin(plugin) method (nepalez)
403
-
404
- ### Bugs Fixed
405
-
406
- * Prevent plugin's registry from polluting superclass (nepalez)
407
-
408
- [Compare v0.2.1...v0.3.0](https://github.com/dry-rb/dry-initializer/compare/v0.2.1...v0.3.0)
409
-
410
- ### Internals
411
-
412
- * Make all instances (Builder and Signature) immutable (nepalez)
413
- * Decouple mixin from a builder to prevent pollution (nepalez)
414
- * Ensure default value block can use private variables (jeremyf)
415
-
416
- [Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-initializer/compare/v0.2.0...v0.2.1)
417
-
418
- ## v0.2.1 2016-05-19
419
-
420
- ### Bugs Fixed
535
+ ### Fixed
536
+ - Prevent plugin's registry from polluting superclass (nepalez)
421
537
 
422
- * Fix polluting superclass with declarations from subclass (nepalez)
538
+ ### Changed
539
+ - Make all instances (Builder and Signature) immutable (nepalez)
540
+ - Decouple mixin from a builder to prevent pollution (nepalez)
541
+ - Ensure default value block can use private variables (jeremyf)
423
542
 
424
- ### Internals
543
+ ## [0.2.1] [2016-05-19]
425
544
 
426
- * Make all instances (Builder and Signature) immutable (nepalez)
427
- * Decouple mixin from a builder to prevent pollution (nepalez)
428
- * Ensure default value block can use private variables (jeremyf)
545
+ ### Fixed
546
+ - Fix polluting superclass with declarations from subclass (nepalez)
429
547
 
430
- [Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-initializer/compare/v0.2.0...v0.2.1)
548
+ ### Changed
549
+ - Make all instances (Builder and Signature) immutable (nepalez)
550
+ - Decouple mixin from a builder to prevent pollution (nepalez)
551
+ - Ensure default value block can use private variables (jeremyf)
431
552
 
432
- ## v0.2.0 2016-05-16
553
+ ## [0.2.0] [2016-05-16]
433
554
 
434
555
  The gem internals has been rewritten heavily to make the gem pluggable and fix
435
556
  bugs in "container style". Type constraints were extracted to a plugin
@@ -441,15 +562,14 @@ object, and apply value coercion via `dry-types`.
441
562
  Default assignments became slower (while plain type constraint are not)!
442
563
 
443
564
  ### Changed (backward-incompatible changes)
444
-
445
- * Make dry-types constraint to coerce variables (nepalez)
565
+ - Make dry-types constraint to coerce variables (nepalez)
446
566
 
447
567
  ```ruby
448
568
  # This will coerce `name: :foo` to `"foo"`
449
569
  option :name, type: Dry::Types::Coercible::String
450
570
  ```
451
571
 
452
- * Stop supporing proc type constraint (nepalez)
572
+ - Stop supporing proc type constraint (nepalez)
453
573
 
454
574
  ```ruby
455
575
  option :name, type: ->(v) { String === v } # this does NOT work any more
@@ -469,20 +589,18 @@ Default assignments became slower (while plain type constraint are not)!
469
589
  ```
470
590
 
471
591
  ### Added
472
-
473
- * Support type constraint via every object's case equality (nepalez)
592
+ - Support type constraint via every object's case equality (nepalez)
474
593
 
475
594
  ```ruby
476
595
  option :name, type: /foo/
477
596
  option :name, type: (1...14)
478
597
  ```
479
598
 
480
- * Support defaults and type constraints for the "container" syntax (nepalez)
481
- * Support adding extensions via plugin system (nepalez)
599
+ - Support defaults and type constraints for the "container" syntax (nepalez)
600
+ - Support adding extensions via plugin system (nepalez)
482
601
 
483
602
  ### Internal
484
-
485
- * Private method `##__after_initialize__` is added by the `Mixin` along with `#initialize` (nepalez)
603
+ - Private method `##__after_initialize__` is added by the `Mixin` along with `#initialize` (nepalez)
486
604
 
487
605
  The previous implementation required defaults and types to be stored in the class method `.initializer_builder`.
488
606
  That made "container" syntax to support neither defaults nor types.
@@ -492,31 +610,56 @@ Default assignments became slower (while plain type constraint are not)!
492
610
  They are made inside `##__after_initialize__` callback, that is biult via `default_method(&block)`
493
611
  using instance evals.
494
612
 
495
- [Compare v0.1.1...v0.2.0](https://github.com/dry-rb/dry-initializer/compare/v0.1.1...v0.2.0)
496
-
497
- ## v0.1.1 2016-04-28
613
+ ## [0.1.1] [2016-04-28]
498
614
 
499
615
  ### Added
616
+ - `include Dry::Initializer.define -> do ... end` syntax (flash-gordon)
500
617
 
501
- * `include Dry::Initializer.define -> do ... end` syntax (flash-gordon)
502
-
503
- [Compare v0.1.0...v0.1.1](https://github.com/dry-rb/dry-initializer/compare/v0.1.0...v0.1.1)
504
-
505
- ## v0.1.0 2016-04-26
618
+ ## [0.1.0] [2016-04-26]
506
619
 
507
620
  Class DSL splitted to mixin and container versions (thanks to @AMHOL for the idea).
508
621
  Backward compatibility is broken.
509
622
 
510
623
  ### Changed (backward-incompatible changes)
511
-
512
- * Use `extend Dry::Initializer::Mixin` instead of `extend Dry::Initializer` (nepalez)
624
+ - Use `extend Dry::Initializer::Mixin` instead of `extend Dry::Initializer` (nepalez)
513
625
 
514
626
  ### Added
627
+ - Use `include Dry::Initializer.define(&block)` as an alternative to extending the class (nepalez)
515
628
 
516
- * Use `include Dry::Initializer.define(&block)` as an alternative to extending the class (nepalez)
517
-
518
- [Compare v0.0.1...v0.1.0](https://github.com/dry-rb/dry-initializer/compare/v0.0.1...v0.1.0)
519
-
520
- ## v0.0.1 2016-04-09
629
+ ## [0.0.1] [2016-04-09]
521
630
 
522
631
  First public release
632
+
633
+ [0.1.0]: https://github.com/dry-rb/dry-initializer/compare/v0.0.1...v0.1.0
634
+ [0.1.1]: https://github.com/dry-rb/dry-initializer/compare/v0.1.0...v0.1.1
635
+ [0.2.0]: https://github.com/dry-rb/dry-initializer/compare/v0.1.1...v0.2.0
636
+ [0.2.1]: https://github.com/dry-rb/dry-initializer/compare/v0.2.0...v0.2.1
637
+ [0.2.1]: https://github.com/dry-rb/dry-initializer/compare/v0.2.0...v0.2.1
638
+ [0.3.0]: https://github.com/dry-rb/dry-initializer/compare/v0.2.1...v0.3.0
639
+ [0.3.1]: https://github.com/dry-rb/dry-initializer/compare/v0.3.0...v0.3.1
640
+ [0.3.2]: https://github.com/dry-rb/dry-initializer/compare/v0.3.1...v0.3.2
641
+ [0.3.3]: https://github.com/dry-rb/dry-initializer/compare/v0.3.2...v0.3.3
642
+ [0.4.0]: https://github.com/dry-rb/dry-initializer/compare/v0.3.3...v0.4.0
643
+ [0.5.0]: https://github.com/dry-rb/dry-initializer/compare/v0.4.0...v0.5.0
644
+ [0.6.0]: https://github.com/dry-rb/dry-initializer/compare/v0.5.0...v0.6.0
645
+ [0.7.0]: https://github.com/dry-rb/dry-initializer/compare/v0.6.0...v0.7.0
646
+ [0.8.0]: https://github.com/dry-rb/dry-initializer/compare/v0.7.0...v0.8.0
647
+ [0.8.1]: https://github.com/dry-rb/dry-initializer/compare/v0.8.0...v0.8.1
648
+ [0.9.0]: https://github.com/dry-rb/dry-initializer/compare/v0.8.1...v0.9.0
649
+ [0.9.1]: https://github.com/dry-rb/dry-initializer/compare/v0.9.0...v0.9.1
650
+ [0.9.2]: https://github.com/dry-rb/dry-initializer/compare/v0.9.1...v0.9.2
651
+ [0.9.3]: https://github.com/dry-rb/dry-initializer/compare/v0.9.2...v0.9.3
652
+ [0.10.0]: https://github.com/dry-rb/dry-initializer/compare/v0.9.3...v0.10.0
653
+ [0.10.1]: https://github.com/dry-rb/dry-initializer/compare/v0.10.0...v0.10.1
654
+ [0.10.2]: https://github.com/dry-rb/dry-initializer/compare/v0.10.1...v0.10.2
655
+ [0.11.0]: https://github.com/dry-rb/dry-initializer/compare/v0.10.2...v0.11.0
656
+ [1.0.0]: https://github.com/dry-rb/dry-initializer/compare/v0.11.0...v1.0.0
657
+ [1.1.0]: https://github.com/dry-rb/dry-initializer/compare/v1.0.0...v1.1.0
658
+ [1.1.1]: https://github.com/dry-rb/dry-initializer/compare/v1.1.0...v1.1.1
659
+ [1.1.2]: https://github.com/dry-rb/dry-initializer/compare/v1.1.1...v1.1.2
660
+ [1.1.3]: https://github.com/dry-rb/dry-initializer/compare/v1.1.2...v1.1.3
661
+ [1.2.0]: https://github.com/dry-rb/dry-initializer/compare/v1.1.3...v1.2.0
662
+ [1.3.0]: https://github.com/dry-rb/dry-initializer/compare/v1.2.0...v1.3.0
663
+ [1.4.0]: https://github.com/dry-rb/dry-initializer/compare/v1.3.0...v1.4.0
664
+ [1.4.1]: https://github.com/dry-rb/dry-initializer/compare/v1.4.0...v1.4.1
665
+ [2.0.0]: https://github.com/dry-rb/dry-initializer/compare/v1.4.1...v2.0.0