Doesn't work for deeply nested Array and Hashes
First off.. Is this gem still maintained?
I ran into an issue when trying to set a value in a deeply nested structure of Hashes and Arrays. It would throw a TypeError (no implicit conversion of String into Integer) when the parsing reached the array index.
Example
obj = { a: [{ b: 'one', c: 'two' }] }
obj.set_keypath('a.0.b', 'three')
# TypeError (no implicit conversion of String into Integer)
I found a couple issues in the set_keypath method that needs to be addressed to support this scenario. Are you interested in accepting PR's?
Hi @mattgrannary!
Yep, I've been a bit slow responding to issues and PRs across stuff I maintain recently, but I'm following along.
I'd love to see a PR. Do any of the existing open ones help direct an implementation at all? I'll likely merge those soon and cut a new release.
@mattgrannary any chance you fixed this?
@mathiasjakobsen I haven't had a chance to create a PR for this but I have a branch on my fork that solves my issues. I've been using this for the time being.
https://github.com/mattgrannary/keypath-ruby/commit/310b381b4d7121e888d6aa43a0f17b897b782a7b
Feel free to create a PR if you like. I'm sure it just needs some tests to be be ready to go.
@mattgrannary awesome 🎉 Thanks! I'll have a look.
@mattgrannary, do you think you'd be able to open a PR for this?