Skip to content

Releases: dry-rb/dry-initializer

Support of the `initializer` reloading via `super`

02 Jan 17:58
Compare
Choose a tag to compare

ROM integration & support of Ruby 2.4

31 Dec 09:52
Compare
Choose a tag to compare

Bug fix

27 Dec 11:26
Compare
Choose a tag to compare
v0.10.1

Bump v0.10.1

Remove deprecated method `using`

20 Nov 16:31
Compare
Choose a tag to compare
v0.10.0

Update CHANGELOG

Deprecate method `using`

20 Nov 16:26
Compare
Choose a tag to compare

After discussion in PR #17 (many thanks to @sahal2080 and @hrom512 for starting issue and PR), the method using is deprecated and will be removed from v0.10.0.

Fixed validation of param/option names

10 Nov 08:32
Compare
Choose a tag to compare

Support renaming options

06 Nov 21:12
Compare
Choose a tag to compare
class Foo
  include Dry::Initializer::Mixin

  option :bar, as: :foo
end

Foo.new(bar: :BAZ).foo # => :BAZ

Ever-tolerance to options

06 Nov 10:49
Compare
Choose a tag to compare

Default initializer is provided by extending the Mixin (in earlier version it was built only by param or option invocations.

From the very beginning the method accepts any option (ignores unknown ones)

class MyClass
  extend Dry::Initializer::Mixin
end

instance = MyClass.new foo: :bar # undefined options are accepted
instance.respond_to? :foo        # ...but ignored

This was made to provide more consistent behavior (in v0.8.0 tolerance to unknown options occurred all of a sudden after the first option was defined)

Support for `dry-struct`-ish syntax of type constraints

05 Nov 14:18
Compare
Choose a tag to compare

In addition to

param :name, type: Dry::Types['strict.string']

it is possible to use second argument instead of type: option

param :name, Dry::Types['strict.string']

Support for options with "special" names like `option :end`

05 Nov 10:10
Compare
Choose a tag to compare

In this version we switched from key arguments to serialized hash in the initializer:

option :begin
option :end

In previous versions this was translated to

def initialize(begin:, end:)
  @begin = begin # WTF?!
  @end   = end   # BOOM!
end

Now the assignment is implemented like this:

def initialize(**__options__)
  @begin = __options__.fetch(:begin)
  @end   = __options__.fetch(:end)
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.