dry-struct v0.7.0 Release Notes

Release Date: 2019-03-22 // over 2 years ago
  • 🔄 Changed

    • [BREAKING] Struct.input was renamed Struct.schema, hence Struct.schema returns an instance of Dry::Types::Hash::Schema rather than a Hash. Schemas are also implementing Enumerable but they iterate over key types. New API: ruby User.schema.each do |key| puts "Key name: #{ key.name }" puts "Key type: #{ key.type }" end To get a type by its name use .key: ruby User.schema.key(:id) # => #<Dry::Types::Hash::Key ...>
    • [BREAKING] transform_types now passes one argument to the block, an instance of the Key type. Combined with the new API from dry-types it simplifies declaring omittable keys: ruby class StructWithOptionalKeys < Dry::Struct transform_types { |key| key.required(false) } # or simply transform_types(&:omittable) end
    • ⚡️ Dry::Stuct#new is now more efficient for partial updates (flash-gordon)
    • ✅ Ruby 2.3 is EOL and not officially supported. It may work but we don't test it.

    Compare v0.6.0...v0.7.0