Skip to content

Commit

Permalink
Bump v0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nepalez committed Nov 5, 2016
1 parent 8df3d80 commit 647e067
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
50 changes: 50 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,53 @@
## v0.8.0 2016-11-05

In this version we switched from key arguments to ** to support special keys:

option :end
option :begin

In previous versions this was translated to

def initialize(end:, begin:)
@end = end # BOOM! SyntaxError!
@begin = begin # Potential BOOM (unreached)
end

Now the assignment is imlemented like this:

def initialize(**__options__)
@end = __options__.fetch(:end)
@begin = __options__.fetch(:begin)
end

As a side effect of the change the initializer becomes tolerant
to any unknown option if, and only if some `option` was set explicitly.

Methods `tolerant_to_unknown_options` and `intolerant_to_unknown_options`
are deprecated and will be removed in the next version of the gem.

### Added

* support for special options like `option :end`, `option :begin` etc. (@nepalez)

### Internals

* switched from key arguments to serialized hash argument in the initializer (@nepalez)

### Breaking Changes

* the initializer becomes tolerant to unknown options when any `option` was set,
ignoring `intolerant_to_unknown_options` helper.

* the initializer becomes intolerant to options when no `option` was set,
ignoring `tolerant_to_unknown_options` helper.

### Deprecated

* `tolerant_to_unknown_options`
* `intolerant_to_unknown_options`

[Compare v0.7.0...v0.8.0](https://github.com/dry-rb/dry-initializer/compare/v0.7.0..v0.8.0)

## v0.7.0 2016-10-11

### Added
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@ $ gem install dry-initializer

```ruby
require 'dry-initializer'
require 'dry-types'

class User
extend Dry::Initializer::Mixin

# Params of the initializer along with corresponding readers
param :name
param :name, type: Dry::Types["strict.string"]
param :role, default: proc { 'customer' }
# Options of the initializer along with corresponding readers
option :admin, default: proc { false }
option :vip, optional: true
end

# Defines the initializer with params and options
Expand All @@ -61,6 +63,7 @@ user = User.new 'Vladimir', 'admin', admin: true
user.name # => 'Vladimir'
user.role # => 'admin'
user.admin # => true
user.vip # => Dry::Initializer::UNDEFINED
```

See full documentation on the [Dry project official site][docs]
Expand Down
2 changes: 1 addition & 1 deletion dry-initializer.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |gem|
gem.name = "dry-initializer"
gem.version = "0.7.0"
gem.version = "0.8.0"
gem.author = ["Vladimir Kochnev (marshall-lee)", "Andrew Kozin (nepalez)"]
gem.email = ["[email protected]", "[email protected]"]
gem.homepage = "https://github.com/dryrb/dry-initializer"
Expand Down

0 comments on commit 647e067

Please sign in to comment.