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

Register under custom keys (and alias) #4

Closed
AMHOL opened this issue Sep 23, 2015 · 3 comments
Closed

Register under custom keys (and alias) #4

AMHOL opened this issue Sep 23, 2015 · 3 comments
Labels

Comments

@AMHOL
Copy link
Member

AMHOL commented Sep 23, 2015

I think it would be good to allow types to be registered under custom keys, this way we can register under symbol keys and reduce allocations. Would also be good to allow for aliases (i.e. :int => :integer, :bool => :boolean). This should also allow us to get rid of the const_missing definition and I think the interface will be nicer.

Also, perhaps we should move the registration out of Dry::Data::Struct and make it explicit (i.e. Dry::Data.register(:name, Type, aliases: [:alias1, :alias2]).

This should make the library much more flexible, the obvious detriment is that there will be a bit of setup involved. I think it would also be good to make it so that a user can get a container without any of the built in types, and just create Dry::Data container and register the built-in types.

@AMHOL AMHOL added the feature label Sep 23, 2015
@AMHOL
Copy link
Member Author

AMHOL commented Oct 9, 2015

@solnic has already done this ❤️

@AMHOL AMHOL closed this as completed Oct 9, 2015
@solnic
Copy link
Member

solnic commented Oct 9, 2015

I guess I did :) but what about aliasing? you think it could be a useful feature? I'm having doubts

@AMHOL
Copy link
Member Author

AMHOL commented Oct 9, 2015

Nah, there's more than one way to skin a cat, but there probably shouldn't be.

I was just thinking str vs string and int vs integer etc.

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

No branches or pull requests

2 participants