Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of Set #356

Open
dnesteryuk opened this issue Oct 4, 2019 · 3 comments
Open

Support of Set #356

dnesteryuk opened this issue Oct 4, 2019 · 3 comments

Comments

@dnesteryuk
Copy link

Is there a plan to support Set?

I am trying to use dry-types in place of Virtus in Grape. Currently, Set is supported because Virtus supports it.

I am think of the same interface as Array has:

PostStatuses = Types::Set.of(Types::Coercible::String)
@flash-gordon
Copy link
Member

We'll need to generalize some internals for that. Maybe we could do it in 1.3

@Alexxfrolov
Copy link

Are there any ideas about this feat ? I guess it can be very useful

@solnic
Copy link
Member

solnic commented Dec 9, 2020

@Alexxfrolov this is as simple as:

[4] pry(main)> Types::Set = Types.Constructor(Set, Set.method(:new))
=> #<Dry::Types[Constructor<Nominal<Set> fn=Set.new>]>
[5] pry(main)> Types::Set[["a", "a", "b", "c"]]
=> #<Set: {"a", "b", "c"}>

I'm not 100% sure we should have it in the lib though but we'll think about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants