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

Proper/suggested way of demarshalling data? #227

Open
marks opened this issue Sep 10, 2014 · 4 comments
Open

Proper/suggested way of demarshalling data? #227

marks opened this issue Sep 10, 2014 · 4 comments
Labels

Comments

@marks
Copy link

marks commented Sep 10, 2014

First off, thanks for creating and continuing to maintain Hashie. I'm dealing with a use case where all data from the API is returned as strings (in the case of numbers) and there are some fields such as timestamps that I want to convert into Ruby Time objects. Is there a way to do this in Hashie currently with a Dash (it seems like a good extension to me) or is there a suggested way to do this in conjunction with Hashie?

Thanks!

@dblock
Copy link
Member

dblock commented Sep 10, 2014

I think this is definitely a scenario hashie should solve if it doesn't already. If I am not mistaken this is something custom to your app. You would have to know that created_at is actually a DateTime.

You should be able to do this with Hashie::Extensions::Coercion, ie. coerce_key and friends. Did you try this?

@marks
Copy link
Author

marks commented Sep 10, 2014

I haven't yet. I'll look into the coerce extension- thanks!

Mark Silverberg

http://SocialHealthInsights.comhttp://SocialHealthInsights.com
Sent from my iPhone

On Sep 10, 2014, at 12:32 PM, "Daniel Doubrovkine (dB.) @dblockdotorg" <notifications@github.commailto:notifications@github.com> wrote:

I think this is definitely a scenario hashie should solve if it doesn't already. If I am not mistaken this is something custom to your app. You would have to know that created_at is actually a DateTime.

You should be able to do this with Hashie::Extensions::Coercion, ie. coerce_key and friends. Did you try this?

Reply to this email directly or view it on GitHubhttps://github.com//issues/227#issuecomment-55151513.

@chrismetcalf
Copy link

+1! ✊

@michaelherold
Copy link
Member

Building on what dB said earlier, I think this should be able to be easily done using coercion procs. If it's not, show us an example and we can look into creating something that will help you out!

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

4 participants