A summary of data about the Ruby ecosystem.

Recent Releases of https://github.com/dry-rb/dry-initializer

https://github.com/dry-rb/dry-initializer - v3.2.0

Changed

  • Set minimal supported Ruby version to 3.1 (@flash-gordon)
  • Exclude block forwarding from Root#initialize. This helps
    with tracking down calls that shouldn't pass a block in Ruby 3.4 (see #109) (@flash-gordon)

Compare v3.1.1...v3.2.0

- Ruby
Published by dry-bot about 1 year ago

https://github.com/dry-rb/dry-initializer - v3.1.1

Changed

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

Compare v3.1.0...v3.1.1

- Ruby
Published by dry-bot almost 4 years ago

https://github.com/dry-rb/dry-initializer - v3.1.0

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

- Ruby
Published by dry-bot almost 4 years ago

https://github.com/dry-rb/dry-initializer -

Fixed

  • Arity check for lambdas used for coercion (@flash-gordon)

Compare v3.0.3...v3.0.4

- Ruby
Published by flash-gordon over 5 years ago

https://github.com/dry-rb/dry-initializer - Support of wrapped and nested types

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

- Ruby
Published by nepalez over 6 years ago

https://github.com/dry-rb/dry-initializer - Fix coercion of `nil`

- Ruby
Published by nepalez over 7 years ago

https://github.com/dry-rb/dry-initializer - Add dispatchers for extending syntax

- Ruby
Published by nepalez almost 8 years ago

https://github.com/dry-rb/dry-initializer - Type coercer can take second argument for the initialized instance

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

- Ruby
Published by nepalez over 8 years ago

https://github.com/dry-rb/dry-initializer - Provide class-level container

- Ruby
Published by nepalez over 8 years ago

https://github.com/dry-rb/dry-initializer - Support for lambdas as default values

- Ruby
Published by nepalez almost 9 years ago

https://github.com/dry-rb/dry-initializer - Minor fix

Make @__options__ var to slice default options only:
https://github.com/dry-rb/dry-initializer/blob/master/spec/options_var_spec.rb#L33-L37

- Ruby
Published by nepalez almost 9 years ago

https://github.com/dry-rb/dry-initializer - Support gem enhancement

# Prepare a dispatcher for `string: true` option to be alias of `type: proc(&:to_s)`
string_dispatcher = lambda do |string: nil, **op|
  string ? op.merge(type: proc(&:to_s)) : op
end

# Register the dispatcher
Dry::Initializer::Attribute.dispatchers << string_dispatcher

# Now you can use the `:string` key for `param` and `option`
class User
  extend Dry::Initializer
  param  :name, string: true
  option :city, string: true
end

user = User.new(:Andy, city: :Moscow)
user.name # => "Andy"
user.city # => "Moscow"

- Ruby
Published by nepalez almost 9 years ago

https://github.com/dry-rb/dry-initializer - Stable release

- Ruby
Published by nepalez almost 9 years ago

https://github.com/dry-rb/dry-initializer - Bug fix

- Ruby
Published by nepalez about 9 years ago

https://github.com/dry-rb/dry-initializer - Remove deprecated method `using`

- Ruby
Published by nepalez about 9 years ago

https://github.com/dry-rb/dry-initializer - Deprecate method `using`

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.

- Ruby
Published by nepalez about 9 years ago

https://github.com/dry-rb/dry-initializer - Support renaming options

class Foo
  include Dry::Initializer::Mixin

  option :bar, as: :foo
end

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

- Ruby
Published by nepalez about 9 years ago

https://github.com/dry-rb/dry-initializer - Ever-tolerance to options

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)

- Ruby
Published by nepalez about 9 years ago

https://github.com/dry-rb/dry-initializer - Support for `dry-struct`-ish syntax of type constraints

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']

- Ruby
Published by nepalez about 9 years ago

https://github.com/dry-rb/dry-initializer - Support for options with "special" names like `option :end`

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.

- Ruby
Published by nepalez about 9 years ago

https://github.com/dry-rb/dry-initializer - Add `#using` method for shared options

Instead of

param  :foo, reader: :private
option :bar, reader: :private

Use

using reader: :private do
  param  :foo
  option :bar
end

- Ruby
Published by nepalez over 9 years ago

https://github.com/dry-rb/dry-initializer - Support for `private` and `protected` attibute readers

param :id # public reader (default)
param :name,   reader: :private
param :phone,  reader: :protected
param :email,  reader: false # no reader
param :age,    reader: public
param :gender, reader: true # public as well

- Ruby
Published by nepalez over 9 years ago

https://github.com/dry-rb/dry-initializer - Support optional params and options

class User
  extend Dry::Initializer

 param :name, type: Dry::Types['strict.string']
 param :email, type: Dry::Types['strict.string'], default: proc { nil }
 param :phone, type: Dry::Types['strict.string'], optional: true
end

user = User.new "Andrew"

user.name  # => "Andrew"
user.email # => nil (default)
user.phone # => Dry::Types::UNDEFINED (new feature)

- Ruby
Published by nepalez over 9 years ago

https://github.com/dry-rb/dry-initializer - Bug fix

- Ruby
Published by nepalez over 9 years ago

https://github.com/dry-rb/dry-initializer - Support for tolerance to unknown options

Class helpers tolerant_to_unknown_options and intolerant_to_unknown_options allows switching on/off a regime where undeclared options are ignored without error.

- Ruby
Published by nepalez over 9 years ago

https://github.com/dry-rb/dry-initializer - Update Mixin interface for adding plugins

Use Mixin#register_initializer_plugin for adding plugins:

mixin.register_initializer_plugin NewPlugin

instead of:

mixin.initializer_builder.register NewPlugin

- Ruby
Published by nepalez over 9 years ago

https://github.com/dry-rb/dry-initializer - Bug fix

- Ruby
Published by nepalez over 9 years ago

https://github.com/dry-rb/dry-initializer - Support plugin system

- Ruby
Published by nepalez over 9 years ago

https://github.com/dry-rb/dry-initializer - Split module to mixin and container versions

Mixin version

extend Dry::Initializer::Mixin
param :name

Container version

include Dry::Initializer.define {
  param :name
}

- Ruby
Published by nepalez over 9 years ago

https://github.com/dry-rb/dry-initializer - The first public release

- Ruby
Published by nepalez over 9 years ago