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

Make Collection load values when adding them into it #155

Open
blanquer opened this issue Jan 6, 2016 · 0 comments
Open

Make Collection load values when adding them into it #155

blanquer opened this issue Jan 6, 2016 · 0 comments

Comments

@blanquer
Copy link
Contributor

blanquer commented Jan 6, 2016

If you have say, a Collection.of(Attributor::Hash) ... you can easily initialize an instance by calling the .load method. That will propertly load/coerce/convert the elements to the appropriate type (i.e. Attributor::Hash in this case).

However, if you add an element to it (i.e. using <<) we'll blindly store the instance you pass without loading it. Same applies for any native Array methods that set/change elements.

I think we need to override those "settable/updatable" functions and force a load first.

Otherwise, it might look like you're setting the right things (i.e., a ruby Hash, instead of an Attributor::Hash) as one of the elements...but which will then fail validation. Same for Strings vs. Symbols...etc

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

No branches or pull requests

1 participant