v1.3.0
Added
-
Nested structures will reuse type and key transformations from the enclosing struct (@flash-gordon)
class User < Dry::Struct transform_keys(&:to_sym) attribute :name, Types::String attribute :address do # this struct will inherit transform_keys(&:to_sym) attribute :city, Types::String end # nested struct will _not_ transform keys because a parent # struct is given attribute :contacts, Dry::Struct do attribute :email, Types::String end end
-
Dry::Struct::Constructor
finally acts like a fully-featured type (@flash-gordon) -
Dry::Struct.abstract
declares a struct class as abstract. An abstract class is used as a default superclass for nested structs (@flash-gordon) -
Struct.to_ast
and struct compiler (@flash-gordon) -
Struct composition with
Dry::Struct.attributes_from
. It's more flexible than inheritance (@waiting-for-dev + @flash-gordon)class Address < Dry::Struct attribute :city, Types::String attribute :zipcode, Types::String end class Buyer < Dry::Struct attribute :name, Types::String attributes_from Address end class Seller < Dry::Struct attribute :name, Types::String attribute :email, Types::String attributes_from Address end
Changed
- [internal] metadata is now stored inside schema (@flash-gordon)