-
[equalizer] Add
Dry::Core.Equalizer
method to makeinclude Dry::Core.Equalizer(...)
work as documented (via #79) (@timriley)Users of Equalizer should now only need to
require "dry/core"
first.
- Minimal Ruby version is 3.0
- Import dry-container as
Dry::Core::Container
(via #77) (@solnic)
- Correct missing constant for IDENTITY (issue #75 fixed via #76) (@poloka)
- dry-core now uses zeitwerk for autoloading (@solnic)
- [memoizable] plays better with inheritance. There were cases when cached values from base claesses were used, see #70 (@flash-gordon)
Dry::Core::BasicObject
ported from hanami-utils (@jodosha)
- [BREAKING] [descendants tracker] switch to using
Class#subclasses
on Ruby 3.1+. This changes the order of returned subclasses (immediate subclasses now go first) (@flash-gordon)
- [memoizable] memoizable correctly handles cases where a method
has unnamed params (e.g. happens when the new
...
syntax is used) (@flash-gordon)
- [memoizable] warnings when using keyword arguments (@flash-gordon)
- [deprecations] warnings show more relevant information about caller by default (@timriley)
- Minimal Ruby version is 2.6
- [memoizable] memoization of block-accepting methods is deprecated (@flash-gordon)
- [memoizable] support for
BasicObject
(@oleander) - [memoizable] support for methods that accept blocks (@oleander)
- [deprecations] allow printing frame info on warn when setting up Deprecation module (via #52) (@waiting-for-dev)
- [memoizable] works with MRI 2.7+ keyword arguments now (@oleander)
- dry-equalizer has been imported into dry-core as
Dry::Core::Equalizer
but the interface remains the same, which isinclude Dry.Equalizer(...)
- we'll be porting all other gems that depend on dry-equalizer to the latest dry-core with equalizer included gradually. Eventually dry-equalizer usage will be gone completely in rom-rb/dry-rb/hanami projects (@solnic)
ClassAttributes.defines
gets a new option for coercing values (tallica)
class Builder
extend Dry::Core::ClassAttributes
defines :nodes, coerce: -> value { Integer(value) }
end
:coerce
works with any callable as well as types from dry-types
defines :nodes, coerce: Dry::Types['coercible.integer']
Constants::IDENTITY
which is the identity function (flash-gordon)
-
Undefined.coalesce
takes a variable number of arguments and returns the first non-Undefined
value (flash-gordon)Undefined.coalesce(Undefined, Undefined, :foo) # => :foo
Undefined.{dup,clone}
returnsUndefined
back,Undefined
is a singleton (flash-gordon)
-
Undefined.map
for mapping non-undefined values (flash-gordon)something = 1 Undefined.map(something) { |v| v + 1 } # => 2 something = Undefined Undefined.map(something) { |v| v + 1 } # => Undefined
- Fix default logger for deprecations, it now uses
$stderr
by default, as it should (flash-gordon)
- Trigger constant autoloading in the class builder (radar)
Dry::Core::Memoizable
, which provides amemoize
macro for memoizing results of instance methods (timriley)
deprecate_constant
overridesModule#deprecate_constant
and issues a labeled message on accessing a deprecated constant (flash-gordon)Undefined.default
which accepts two arguments and returns the first if it's notUndefined
; otherwise, returns the second one or yields a block (flash-gordon)
Dry::Core::DescendantsTracker
which is a maintained version of thedescendants_tracker
gem (flash-gordon)
- Class attributes now support private setters/getters (flash-gordon)
- Improved error message on invalid attribute value (GustavoCaso)
-
Added the
:type
option to class attributes, you can now restrict attribute values with a type. You can either use plain ruby types (Integer
,String
, etc) ordry-types
(GustavoCaso)class Foo extend Dry::Core::ClassAttributes defines :ruby_attr, type: Integer defines :dry_attr, type: Dry::Types['strict.int'] end
Deprecations
output is set to$stderr
by default now (solnic)
- The Deprecations module now shows the right caller line (flash-gordon)
- Accept an existing logger object in
Dry::Core::Deprecations.set_logger!
(flash-gordon)
- Support for building classes within an existing namespace (flash-gordon)
- Class attributes are initialized before running the
inherited
hook. It's slightly more convenient behavior and it's very unlikely anyone will be affected by this, but technically this is a breaking change (flash-gordon)
- Do not require deprecated method to be defined (flash-gordon)
- Fix warnings on using uninitialized class attributes (flash-gordon)
ClassAttributes
which providesdefines
method for defining get-or-set methods (flash-gordon)
Constants
are now available in nested scopes (flash-gordon)
Initial release