aetherknight / recursive-open-struct

OpenStruct subclass that returns nested hash attributes as RecursiveOpenStructs
Other
276 stars 54 forks source link

Reinstates indifferent access behaviour #33

Closed Kris-LIBIS closed 9 years ago

Kris-LIBIS commented 9 years ago

This fixes issue #32.

Note that indifferent access is implemented differently than Rails' version. My implementation may have a small performance hit, but it has the advantage that the hash keys are not all transformed into strings like in Rails. This prevents unnecessary diffs in roundtripping (e.g. loading from YAML file and saving back).

Kris-LIBIS commented 9 years ago

BTW I added a spec for the indifferent access behaviour, of course.

aetherknight commented 9 years ago

Hmm, your change doesn't work on MRI 1.9.3 or JRuby in 1.9 mode. Perhaps []= was added to OpenStruct in 2.0?

MRI 1.9.x support has ended, but the stable version of JRuby is still pretty entrenched in 1.9 mode in its stable branch (JRuby 9000 is not yet "stable").

aetherknight commented 9 years ago

Also, thank you for adding clear and concise specs, it is much appreciated. =)

Kris-LIBIS commented 9 years ago

OK, thanks for letting me know. I'll look into it, tomorrow.

Kris-LIBIS commented 9 years ago

I added the missing setter method. And as I was working, I also added the other methods that were introduced in Ruby 2.0's OpenStruct.

Kris-LIBIS commented 9 years ago

Thanks. When will you release a new version? I’d like to update my own gem, but it currently fails due to this issue.

From: William (B.J.) Snow Orvis [mailto:notifications@github.com] Sent: woensdag 20 mei 2015 05:50 To: aetherknight/recursive-open-struct Cc: Kris Dekeyser Subject: Re: [recursive-open-struct] Reinstates indifferent access behaviour (#33)

Merged #33https://github.com/aetherknight/recursive-open-struct/pull/33.

— Reply to this email directly or view it on GitHubhttps://github.com/aetherknight/recursive-open-struct/pull/33#event-309141483.

aetherknight commented 9 years ago

I was planning to cut a release last night, but I tried to fix #29 first. I thought i had a solution but I ran into some additional problems after I performed some exploratory testing late last night.

I will cut a release by tonight with your fix. Thanks. When will you release a new version? I’d like to update my own gem, but it currently fails due to this issue.

From: William (B.J.) Snow Orvis [mailto:notifications@github.com] Sent: woensdag 20 mei 2015 05:50 To: aetherknight/recursive-open-struct Cc: Kris Dekeyser Subject: Re: [recursive-open-struct] Reinstates indifferent access behaviour (#33)

Merged #33https://github.com/aetherknight/recursive-open-struct/pull/33.

— Reply to this email directly or view it on GitHub< https://github.com/aetherknight/recursive-open-struct/pull/33#event-309141483>.

— Reply to this email directly or view it on GitHub https://github.com/aetherknight/recursive-open-struct/pull/33#issuecomment-103917729 .