-
Notifications
You must be signed in to change notification settings - Fork 94
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
Struct being converted #249
Comments
I looked at the history and it seems that this behaviour was deliberately added in commit e7a8f12 (includes tests-cases). However, as you mention, the documentation doesn't mention this one-way behaviour: A PR with documentation changes for |
Hmm. Don't remember what the reasoning behind this was.
…On Wed., Jul. 24, 2019, 8:57 a.m. Dov Murik, ***@***.***> wrote:
I looked at the history and it seems that this behaviour was deliberately
added in commit e7a8f12
<e7a8f12>
(includes tests-cases). However, as you mention, the documentation doesn't
mention this one-way behaviour: Hamster.from converts Struct to
Hamster::Hash but Hamster.to_ruby doesn't (cannot) convert it back.
A PR with documentation changes for Hamster.from and Hamster.to_ruby
would be appreciated...
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#249?email_source=notifications&email_token=AAIESX7WJ2RIQCAKFCUNWD3QA74LZA5CNFSM4IF3X5JKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2VLY2Y#issuecomment-514505835>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAIESX2QJ3M2RRGTRWUUP4DQA74LZANCNFSM4IF3X5JA>
.
|
I saw that it was deliberate too, but I think that it probably violates the principle of less surprise, as it looses information on the conversion (something that don't happen if I try to convert only hashes, arrays and sets). I would vote for another solution on Struct's conversion, but if it's not possible an update on documentation would be great too :) |
On Hamster's
Hamster.from
documentation, there's no mention thatStruct
will be converted to a hash, and indeed it is really strange:The problem is that
SomeClass
is not a hash, it is a struct, so this will fail:The problem is that
Hamster.from
loses the struct information, so it's impossible to get back the original object, and the documentation doesn't mention anything.The text was updated successfully, but these errors were encountered: