diff --git a/CHANGELOG.md b/CHANGELOG.md index 1537ceb..68b23c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 38812af..5e99b6a 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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] diff --git a/dry-initializer.gemspec b/dry-initializer.gemspec index 2bab4e1..aeba6ea 100644 --- a/dry-initializer.gemspec +++ b/dry-initializer.gemspec @@ -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 = ["hashtable@yandex.ru", "andrew.kozin@gmail.com"] gem.homepage = "https://github.com/dryrb/dry-initializer"