Hi!
Recently I started using Dry::Struct and face weird behaviour for example with class:
class MyStruct < Dry::Struct
attribute :qwe, Types::String.default('qwe')
attribute :data do
attribute? :foo, Types::Bool.default(false)
attribute :bar, Types::Array.default([].freeze)
end
end
And here is confusion on initialize:
MyStruct.new => # {qwe: 'qwe',data: {foo: false, bar: []}}
MyStruct.new(qwe: 'asd') => # {qwe: 'asd', data: nil}
Digging code founded that default_attributes
are being used only when no attributes passed.
Is it intended?
Why not just simple merge?