flash-gordon on master
Remove unreachable method (compare)
flash-gordon on master
Remove Dry::Types.type_keys It… (compare)
flash-gordon on master
Remove unreachable code (compare)
flash-gordon on master
Coverage for function.rb (compare)
flash-gordon on fix-maybe-call-safe
flash-gordon on master
Fix behavior of Maybe#call_safe… Merge pull request #380 from dr… (compare)
flash-gordon on fix-maybe-call-safe
Fix behavior of Maybe#call_safe… (compare)
flash-gordon on fix-maybe-call-safe
Fix behavior of Maybe#call_safe… (compare)
flash-gordon on fix-maybe-try
flash-gordon on master
Fix behavior of Types::Maybe#try Merge pull request #379 from dr… (compare)
flash-gordon on master
Fix typo Merge pull request #67 from gru… (compare)
flash-gordon on fix-maybe-try
Fix behavior of Types::Maybe#try (compare)
flash-gordon on master
Lax coverage (compare)
constructor_type
. Can someone point me in the direction of how to make all attributes omittable, without explicitly having to set .meta(omittable: true)
? I used constructor_type :schema
to get around it before..
class User < Dry::Struct
transform_types do |type|
type.meta(omittable: true)
end
attribute :name, Types::Strict::String
attribute :age, Types::Strict::Integer.default(18)
end
class User < Dry::Struct
transform_types do |type|
type.meta(omittable: true)
end
attribute :foo, Types::Hash.default(Hash.new)
end
User.new.foo # => {:meta=>{:omittable=>true}}
Dry::Struct::Error: [User.new] :name is missing in Hash input
User.new.foo # => {:meta=>{:omittable=>true}}
I'm trying to get User.new.foo # => {}
(which is what constructor_type :schema
did before)
class User < Dry::Struct
transform_types do |type|
type.optional.deafult({})
end
attribute :foo, Types::Hash
end
class User < Dry::Struct
transform_types do |type|
if type.default?
type
else
type.meta(omittable: true)
end
end
attribute :foo, Types::Hash.default({})
attribute :bar, Types::String
end
User.new
=> #<User foo={} bar=nil>
transform_types
many times
constructor_type :schema
style :P )