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
Hashie#deep_find_all not working #327
Comments
Check against HEAD please, maybe #319 fixed it? If not write a spec that reproduces the problem? Thx. |
hi @dblock thanks for getting back so quick. I've forked the project/created a branch that has a spec that demonstrates the issue https://github.com/derekyau/hashie/tree/deep_find_all_bug |
@dblock I've done a first go at attempting to fix this bug. I'm not sure whether there's a better way to do it, so for now I've just committed it in my branch here: derekyau@628dd1c I've added a few more specs to catch more cases. Let me know what you think, cheers. |
Found an issue with what my current implementation does - if the object that matches is an Array, the elements in the array get added directly to the matches even though its the Array itself that should be added (this is in fact true, but since I call .flatten at the end we lose the visibility). Otherwise, seems to work - I'll circle back sometime and see if there's something that can be done about this, its also not in the spec, so I'll write that up sometime as well to have it failing Let me know if there are further suggestions |
Thanks @derekyau. Make pull requests please! |
hey @dblock sorry haven't had time to look at this in awhile but it came up in another project recently. I was tracing the commit history on |
You mean should we merge #329? If it passed specs then possibly ;) |
yes :) maybe go through it on a high level to see if you agree? Specs do pass. What I meant to say was that I realized deep_find changed from commit 36ece58 to b3c123c and actually the code from the earlier commit I believe actually works to spec. I pit that code against my updated specs to see if it would pass and it does. |
@dblock any further thoughts? Would love to get this fixed on master so I don't have to reference my branch :) |
@dblock got it thanks, sorry didn't notice it. i'll get to it asap |
This was resolved by #378. Here's the verification: $ bin/console
[1] pry(main)> user = { name: { first: 'Bob', last: 'Boberts' }, groups: [ { name: 'Rubyists' }, { name: 'Open source enthusiasts' } ] }
=> {:name=>{:first=>"Bob", :last=>"Boberts"}, :groups=>[{:name=>"Rubyists"}, {:name=>"Open source enthusiasts"}]}
[2] pry(main)> user.extend Hashie::Extensions::DeepFind
=> {:name=>{:first=>"Bob", :last=>"Boberts"}, :groups=>[{:name=>"Rubyists"}, {:name=>"Open source enthusiasts"}]}
[3] pry(main)> user.deep_find_all(:name)
=> [{:first=>"Bob", :last=>"Boberts"}, "Rubyists", "Open source enthusiasts"] |
I'm having an issue being able with the example in the documentation.
Ruby version: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
When I try to run
user.deep_find_all(:name)
I only get the result as[{:first=>"Bob", :last=>"Boberts"}]
which is wrong because it doesn't include the nested values as it should.when I remove the top level 'name' key from the user hash and run the code again, I do get the two values
Rubyists
andOpen source enthusiasts
.Am I missing something? Or is this not working?
The text was updated successfully, but these errors were encountered: