Skip to content

Releases: dry-rb/dry-initializer

v3.1.1

19 Jan 09:24
v3.1.1
Compare
Choose a tag to compare

Changed

  • Improved error messages were rolled back, they created an implicit dependency on dry-types (@flash-gordon)

Compare v3.1.0...v3.1.1

v3.1.0

16 Jan 08:15
v3.1.0
f32f141
Compare
Choose a tag to compare

Changed

  • Improved error messages on type mismatch (@swerling)
  • [BREAKING] Minimal supported Ruby version is 2.7 (@flash-gordon)

Compare v3.0.4...v3.1.0

v3.0.4

30 Sep 06:56
v3.0.4
Compare
Choose a tag to compare

Fixed

Compare v3.0.3...v3.0.4

Fix underscored names of param/option-s

15 Apr 20:48
Compare
Choose a tag to compare
v3.0.1

Fix validation of underscored names

Support of wrapped and nested types

14 Apr 17:23
Compare
Choose a tag to compare
class Test
  extend Dry::Initializer

  # Wrapped type
  option :foo, [proc(&:to_s)]

  # Nested type
  option :bar do
    option :baz, proc(&:to_s)
  end

  # Both wrapped and nested type
  option :qux, [] do
    option :sax, proc(&:to_s)
  end
end

test = Test.new foo: 4, bar: { baz: 5 }, qux: { sax: 6 }

# Wrapped type wraps a coerced value to array
test.foo # => ["4"]

# Nested type builds the nested structure
test.bar.baz # => "5"

# Their composition wraps the result of nesting
test.qux.first.sax # => 6

Fix coercion of `nil`

09 Sep 10:54
Compare
Choose a tag to compare
v2.6.0

Bump v2.6.0

Switch operands to test for undefined attrs

16 Aug 23:02
Compare
Choose a tag to compare

Add dispatchers for extending syntax

02 Feb 21:21
Compare
Choose a tag to compare

Type coercer can take second argument for the initialized instance

19 Sep 08:16
Compare
Choose a tag to compare

This allows to wrap assigned value to the object that refers back
to the initializer instance. More verbose example:

class Location < String
  attr_reader :parameter # refers back to its parameter

  def initialize(name, parameter)
    super(name)
    @parameter = parameter
  end
end

class Parameter
  extend Dry::Initializer
  param :name
  param :location, ->(value, param) { Location.new(value, param) }
end

offset = Parameter.new "offset", location: "query"
offset.name     # => "offset"
offset.location # => "query"
offset.location.parameter == offset # true

Add option `:desc` to param/option, and `#inch` to the initializer's config

13 Sep 13:37
Compare
Choose a tag to compare