Upgrading to 4.0

This commit is contained in:
Bobby McDonald 2019-08-16 17:40:29 -04:00
parent 157c3ecc62
commit 9b3209c8d9
No known key found for this signature in database
GPG Key ID: CAD931A49619329A
2 changed files with 42 additions and 2 deletions

View File

@ -15,9 +15,12 @@ scheme are considered to be bugs.
* [#323](https://github.com/intridea/hashie/pull/323): Added `Hashie::Extensions::Mash::DefineAccessors` - [@marshall-lee](https://github.com/marshall-lee).
* [#474](https://github.com/intridea/hashie/pull/474): Expose `YAML#safe_load` options in `Mash#load` - [@riouruma](https://github.com/riouruma), [@dblock](https://github.com/dblock).
* [#478](https://github.com/intridea/hashie/pull/478): Added optional array parameter to `Hashie::Mash.disable_warnings` - [@bobbymcwho](https://github.com/bobbymcwho).
* [#481](https://github.com/intridea/hashie/pull/481): Ruby 2.6 - Support Hash#merge and #merge! called with multiple Hashes/Mashes - [@bobbymcwho](https://github.com/bobbymcwho).
* Your contribution here.
### Changed
* [#481](https://github.com/intridea/hashie/pull/481): Implement non-destructive standard Hash methods - [@bobbymcwho](https://github.com/bobbymcwho).
* Your contribution here.
### Deprecated

View File

@ -1,6 +1,45 @@
Upgrading Hashie
================
### Upgrading to 4.0.0
#### Non-destructive Hash methods called on Mash
The following non-destructive Hash methods called on Mash will now return an instance of the class it was called on.
| method | ruby |
| ----------------- | ---- |
| #compact | |
| #invert | |
| #reject | |
| #select | |
| #slice | 2.5 |
| #transform_keys | 2.5 |
| #transform_values | 2.4 |
```ruby
class Parents < Hashie::Mash; end
parents = Parents.new(father: 'Dad', mother: 'Mom')
cool_parents = parents.transform_values { |v| v + v[-1] + 'io'}
p cool_parents
# before:
{"father"=>"Daddio", "mother"=>"Mommio"}
=> {"father"=>"Daddio", "mother"=>"Mommio"}
# after:
#<Parents father="Daddio" mother="Mommio">
=> {"father"=>"Dad", "mother"=>"Mom"}
```
This may make places where you had to re-make the Mash redundant, and may cause unintended side effects if your application was expecting a plain old ruby Hash.
### Ruby 2.6: Mash#merge and Mash#merge!
In Ruby > 2.6.0, Hashie now supports passing multiple hash and Mash objects to Mash#merge and Mash#merge!.
### Upgrading to 3.7.0
#### Mash#load takes options
@ -200,5 +239,3 @@ instance.to_hash # => { :first => 'First', "last" => 'Last' }
The behavior with `symbolize_keys` and `stringify_keys` is unchanged.
See [#152](https://github.com/intridea/hashie/pull/152) for more information.