keypath-ruby icon indicating copy to clipboard operation
keypath-ruby copied to clipboard

Doesn't work for deeply nested Array and Hashes

Open mattxyzeth opened this issue 7 years ago • 5 comments

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?

mattxyzeth avatar Oct 10 '18 19:10 mattxyzeth

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.

nickcharlton avatar Nov 28 '18 21:11 nickcharlton

@mattgrannary any chance you fixed this?

mathiasjakobsen avatar Apr 11 '19 12:04 mathiasjakobsen

@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.

mattxyzeth avatar Apr 11 '19 12:04 mattxyzeth

@mattgrannary awesome 🎉 Thanks! I'll have a look.

mathiasjakobsen avatar Apr 11 '19 13:04 mathiasjakobsen

@mattgrannary, do you think you'd be able to open a PR for this?

nickcharlton avatar Feb 18 '20 10:02 nickcharlton