Skip to content

Commit 66fb7cc

Browse files
authored
Update CHANGELOG [skip ci]
1 parent 956fff2 commit 66fb7cc

File tree

1 file changed

+63
-40
lines changed

1 file changed

+63
-40
lines changed

CHANGELOG.md

Lines changed: 63 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,35 @@
1+
# 1.1.0 2019-10-07
2+
3+
## Added
4+
5+
- Experimental support for pattern matching :tada: (flash-gordon)
6+
7+
```ruby
8+
User = Dry.Struct(name: 'string', email: 'string')
9+
10+
user = User.new(name: 'John Doe', email: '[email protected]')
11+
12+
case user
13+
in User({ name: 'John Doe', email: })
14+
puts email
15+
else
16+
puts 'Not John'
17+
end
18+
```
19+
20+
See more examples in the [specs](https://github.com/dry-rb/dry-struct/blob/956fff208296731c40f1fea04b36106ea01b56d0/spec/dry/struct/pattern_matching_spec.rb).
21+
22+
[Compare v1.0.0...v1.1.0](https://github.com/dry-rb/dry-struct/compare/v1.0.0...v1.1.0)
23+
124
# 1.0.0 2019-04-23
225

326
## Changed
427

5-
* `valid?` and `===` behave differently, `===` works the same way `Class#===` does and `valid?` checks if the value _can be_ coerced to the struct (flash-gordon)
28+
- `valid?` and `===` behave differently, `===` works the same way `Class#===` does and `valid?` checks if the value _can be_ coerced to the struct (flash-gordon)
629

730
## Added
831

9-
* `Struct.call` now accepts an optional block that will be called on failed coercion. This behavior is consistent with dry-types 1.0. Note that `.new` doesn't take a block (flash-gordon)
32+
- `Struct.call` now accepts an optional block that will be called on failed coercion. This behavior is consistent with dry-types 1.0. Note that `.new` doesn't take a block (flash-gordon)
1033
```ruby
1134
User = Dry::Struct(name: 'string')
1235
User.(1) { :oh_no }
@@ -19,7 +42,7 @@
1942

2043
## Changed
2144

22-
* [BREAKING] `Struct.input` was renamed `Struct.schema`, hence `Struct.schema` returns an instance of `Dry::Types::Hash::Schema` rather than a `Hash`. Schemas are also implementing `Enumerable` but they iterate over key types.
45+
- [BREAKING] `Struct.input` was renamed `Struct.schema`, hence `Struct.schema` returns an instance of `Dry::Types::Hash::Schema` rather than a `Hash`. Schemas are also implementing `Enumerable` but they iterate over key types.
2346
New API:
2447
```ruby
2548
User.schema.each do |key|
@@ -31,28 +54,28 @@
3154
```ruby
3255
User.schema.key(:id) # => #<Dry::Types::Hash::Key ...>
3356
```
34-
* [BREAKING] `transform_types` now passes one argument to the block, an instance of the `Key` type. Combined with the new API from dry-types it simplifies declaring omittable keys:
57+
- [BREAKING] `transform_types` now passes one argument to the block, an instance of the `Key` type. Combined with the new API from dry-types it simplifies declaring omittable keys:
3558
```ruby
3659
class StructWithOptionalKeys < Dry::Struct
3760
transform_types { |key| key.required(false) }
3861
# or simply
3962
transform_types(&:omittable)
4063
end
4164
```
42-
* `Dry::Stuct#new` is now more efficient for partial updates (flash-gordon)
43-
* Ruby 2.3 is EOL and not officially supported. It may work but we don't test it.
65+
- `Dry::Stuct#new` is now more efficient for partial updates (flash-gordon)
66+
- Ruby 2.3 is EOL and not officially supported. It may work but we don't test it.
4467

4568
[Compare v0.6.0...v0.7.0](https://github.com/dry-rb/dry-struct/compare/v0.6.0...v0.7.0)
4669

4770
# v0.6.0 2018-10-24
4871

4972
## Changed
5073

51-
* [BREAKING] `Struct.attribute?` in the old sense is deprecated, use `has_attribute?` as a replacement
74+
- [BREAKING] `Struct.attribute?` in the old sense is deprecated, use `has_attribute?` as a replacement
5275

5376
## Added
5477

55-
* `Struct.attribute?` is an easy way to define omittable attributes (flash-gordon):
78+
- `Struct.attribute?` is an easy way to define omittable attributes (flash-gordon):
5679

5780
```ruby
5881
class User < Dry::Struct
@@ -64,19 +87,19 @@
6487

6588
## Fixed
6689

67-
* `Struct#to_h` recursively converts hash values to hashes, this was done to be consistent with current behavior for arrays (oeoeaio + ZimbiX)
90+
- `Struct#to_h` recursively converts hash values to hashes, this was done to be consistent with current behavior for arrays (oeoeaio + ZimbiX)
6891

6992
[Compare v0.5.1...v0.6.0](https://github.com/dry-rb/dry-struct/compare/v0.5.1...v0.6.0)
7093

7194
# v0.5.1 2018-08-11
7295

7396
## Fixed
7497

75-
* Constant resolution is now restricted to the current module when structs are automatically defined using the block syntax. This shouldn't break any existing code (piktur)
98+
- Constant resolution is now restricted to the current module when structs are automatically defined using the block syntax. This shouldn't break any existing code (piktur)
7699

77100
## Added
78101

79-
* Pretty print extension (ojab)
102+
- Pretty print extension (ojab)
80103
```ruby
81104
Dry::Struct.load_extensions(:pretty_print)
82105
PP.pp(user)
@@ -92,14 +115,14 @@
92115

93116
## BREAKING CHANGES
94117

95-
* `constructor_type` was removed, use `transform_types` and `transform_keys` as a replacement (see below)
96-
* Default types are evaluated _only_ on missing values. Again, use `tranform_types` as a work around for `nil`s
97-
* Values are now stored within a single instance variable names `@attributes`, this sped up struct creation and improved support for reserved attribute names such as `hash`, they don't get a getter but still can be read via `#[]`
98-
* Ruby 2.3 is a minimal supported version
118+
- `constructor_type` was removed, use `transform_types` and `transform_keys` as a replacement (see below)
119+
- Default types are evaluated _only_ on missing values. Again, use `tranform_types` as a work around for `nil`s
120+
- Values are now stored within a single instance variable names `@attributes`, this sped up struct creation and improved support for reserved attribute names such as `hash`, they don't get a getter but still can be read via `#[]`
121+
- Ruby 2.3 is a minimal supported version
99122

100123
## Added
101124

102-
* `Dry::Struct.transform_types` accepts a block which is yielded on every type to add. Since types are `dry-types`' objects that come with a robust DSL it's rather simple to restore the behavior of `constructor_type`. See https://github.com/dry-rb/dry-struct/pull/64 for details (flash-gordon)
125+
- `Dry::Struct.transform_types` accepts a block which is yielded on every type to add. Since types are `dry-types`' objects that come with a robust DSL it's rather simple to restore the behavior of `constructor_type`. See https://github.com/dry-rb/dry-struct/pull/64 for details (flash-gordon)
103126

104127
Example: evaluate defaults on `nil` values
105128

@@ -111,17 +134,17 @@
111134
end
112135
```
113136

114-
* `Data::Struct.transform_keys` accepts a block/proc that transforms keys of input hashes. The most obvious usage is simbolization but arbitrary transformations are allowed (flash-gordon)
137+
- `Data::Struct.transform_keys` accepts a block/proc that transforms keys of input hashes. The most obvious usage is simbolization but arbitrary transformations are allowed (flash-gordon)
115138

116-
* `Dry.Struct` builds a struct by a hash of attribute names and types (citizen428)
139+
- `Dry.Struct` builds a struct by a hash of attribute names and types (citizen428)
117140

118141
```ruby
119142
User = Dry::Struct(name: 'strict.string') do
120143
attribute :email, 'strict.string'
121144
end
122145
```
123146

124-
* Support for `Struct.meta`, note that `.meta` returns a _new class_ (flash-gordon)
147+
- Support for `Struct.meta`, note that `.meta` returns a _new class_ (flash-gordon)
125148

126149
```ruby
127150
class User < Dry::Struct
@@ -133,7 +156,7 @@
133156
User.new(name: 'Jade').class == UserWithMeta.new(name: 'Jade').class # => false
134157
```
135158

136-
* `Struct.attribute` yields a block with definition for nested structs. It defines a nested constant for the new struct and supports arrays (AMHOL + flash-gordon)
159+
- `Struct.attribute` yields a block with definition for nested structs. It defines a nested constant for the new struct and supports arrays (AMHOL + flash-gordon)
137160

138161
```ruby
139162
class User < Dry::Struct
@@ -153,87 +176,87 @@
153176

154177
## Fixed
155178

156-
* Adding a new attribute invalidates `attribute_names` (flash-gordon)
157-
* Struct classes track subclasses and define attributes in them, now it doesn't matter whether you define attributes first and _then_ subclass or vice versa. Note this can lead to memory leaks in Rails environment when struct classes are reloaded (flash-gordon)
179+
- Adding a new attribute invalidates `attribute_names` (flash-gordon)
180+
- Struct classes track subclasses and define attributes in them, now it doesn't matter whether you define attributes first and _then_ subclass or vice versa. Note this can lead to memory leaks in Rails environment when struct classes are reloaded (flash-gordon)
158181

159182
[Compare v0.4.0...v0.5.0](https://github.com/dry-rb/dry-struct/compare/v0.4.0...v0.5.0)
160183

161184
# v0.4.0 2017-11-04
162185

163186
## Changed
164187

165-
* Attribute readers don't override existing instance methods (solnic)
166-
* `Struct#new` uses raw attributes instead of method calls, this makes the behavior consistent with the change above (flash-gordon)
167-
* `constructor_type` now actively rejects `:weak` and `:symbolized` values (GustavoCaso)
188+
- Attribute readers don't override existing instance methods (solnic)
189+
- `Struct#new` uses raw attributes instead of method calls, this makes the behavior consistent with the change above (flash-gordon)
190+
- `constructor_type` now actively rejects `:weak` and `:symbolized` values (GustavoCaso)
168191

169192
## Fixed
170193

171-
* `Struct#new` doesn't call `.to_hash` recursively (flash-gordon)
194+
- `Struct#new` doesn't call `.to_hash` recursively (flash-gordon)
172195

173196
[Compare v0.3.1...v0.4.0](https://github.com/dry-rb/dry-struct/compare/v0.3.1...v0.4.0)
174197

175198
# v0.3.1 2017-06-30
176199

177200
## Added
178201

179-
* `Struct.constructor` that makes dry-struct more aligned with dry-types; now you can have a struct with a custom constructor that will be called _before_ calling the `new` method (v-kolesnikov)
180-
* `Struct.attribute?` and `Struct.attribute_names` for introspecting struct attributes (flash-gordon)
181-
* `Struct#__new__` is a safe-to-use-in-gems alias for `Struct#new` (flash-gordon)
202+
- `Struct.constructor` that makes dry-struct more aligned with dry-types; now you can have a struct with a custom constructor that will be called _before_ calling the `new` method (v-kolesnikov)
203+
- `Struct.attribute?` and `Struct.attribute_names` for introspecting struct attributes (flash-gordon)
204+
- `Struct#__new__` is a safe-to-use-in-gems alias for `Struct#new` (flash-gordon)
182205

183206
[Compare v0.3.0...v0.3.1](https://github.com/dry-rb/dry-struct/compare/v0.3.0...v0.3.1)
184207

185208
# v0.3.0 2017-05-05
186209

187210
## Added
188211

189-
* `Dry::Struct#new` method to return new instance with applied changeset (Kukunin)
212+
- `Dry::Struct#new` method to return new instance with applied changeset (Kukunin)
190213

191214
## Fixed
192215

193-
* `.[]` and `.call` does not coerce subclass to superclass anymore (Kukunin)
194-
* Raise ArgumentError when attribute type is a string and no value provided is for `new` (GustavoCaso)
216+
- `.[]` and `.call` does not coerce subclass to superclass anymore (Kukunin)
217+
- Raise ArgumentError when attribute type is a string and no value provided is for `new` (GustavoCaso)
195218

196219
## Changed
197220

198-
* `.new` without arguments doesn't use nil as an input for non-default types anymore (flash-gordon)
221+
- `.new` without arguments doesn't use nil as an input for non-default types anymore (flash-gordon)
199222

200223
[Compare v0.2.1...v0.3.0](https://github.com/dry-rb/dry-struct/compare/v0.2.1...v0.3.0)
201224

202225
# v0.2.1 2017-02-27
203226

204227
## Fixed
205228

206-
* Fixed `Dry::Struct::Value` which appeared to be broken in the last release (flash-gordon)
229+
- Fixed `Dry::Struct::Value` which appeared to be broken in the last release (flash-gordon)
207230

208231
[Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-struct/compare/v0.2.0...v0.2.1)
209232

210233
# v0.2.0 2016-02-26
211234

212235
## Changed
213236

214-
* Struct attributes can be overridden in a subclass (flash-gordon)
237+
- Struct attributes can be overridden in a subclass (flash-gordon)
215238

216239
[Compare v0.1.1...v0.2.0](https://github.com/dry-rb/dry-struct/compare/v0.1.1...v0.2.0)
217240

218241
# v0.1.1 2016-11-13
219242

220243
## Fixed
221244

222-
* Make `Dry::Struct` act as a constrained type. This fixes the behavior of sum types containing structs (flash-gordon)
245+
- Make `Dry::Struct` act as a constrained type. This fixes the behavior of sum types containing structs (flash-gordon)
223246

224247
[Compare v0.1.0...v0.1.1](https://github.com/dry-rb/dry-struct/compare/v0.1.0...v0.1.1)
225248

226249
# v0.1.0 2016-09-21
227250

228251
## Added
229252

230-
* `:strict_with_defaults` constructor type (backus)
253+
- `:strict_with_defaults` constructor type (backus)
231254

232255
## Changed
233256

234-
* [BREAKING] `:strict` was renamed to `:permissive` as it ignores missing keys (backus)
235-
* [BREAKING] `:strict` now raises on unexpected keys (backus)
236-
* Structs no longer auto-register themselves in the types container as they implement `Type` interface and we don't have to wrap them in `Type::Definition` (flash-gordon)
257+
- [BREAKING] `:strict` was renamed to `:permissive` as it ignores missing keys (backus)
258+
- [BREAKING] `:strict` now raises on unexpected keys (backus)
259+
- Structs no longer auto-register themselves in the types container as they implement `Type` interface and we don't have to wrap them in `Type::Definition` (flash-gordon)
237260

238261
[Compare v0.0.1...v0.1.0](https://github.com/dry-rb/dry-struct/compare/v0.0.1...v0.1.0)
239262

0 commit comments

Comments
 (0)