When I tried calling this DeepLocate I get a stack level error. Any clues as to why? My class is as follows:
Fyi, just released 3.4.1.
3.4.1 (3/31/2015)
#269: Added Hashie::Extensions::DeepLocate - @msievers.
#270: Fixed ArgumentError raised when using IndifferentAccess and HashWithIndifferentAccess - @gardenofwine.
#281: Added #reverse_merge to Mash to override ActiveSupport's version - @mgold.
#282: Fixed coercions in a subclass accumulating in the superclass - @maxlinc, @martinstreicher.
Hey All, I have a bit of a problem and I'm unable to find what I need. I'm newer to ruby so please forgive me. here is my API response that I get from rest client: "{\"status\":0,\"value\":{\"build\":{\"version\":\"1.4.8\",\"revision\":\"c8179bd8352d3c62d98fa58b324491230df9342a\"}}}"
I placed this into a HASH and then tried to use Hashie to assign the "version" to a attribute to a class.
What I come up with is
var.deep_fetch :value, :build, :version
=> "1.4.8"
What I was hoping to be able to assign the attributes a cleaner way. IDEAS?
@xsmaster You could try using #deep_find instead.
https://github.com/intridea/hashie/blob/master/lib/hashie/extensions/deep_find.rb
So it would look something like:
hash.extend(Hashie::Extensions::DeepFind)
hash.deep_find(:version) #=> "1.4.8"
So i found this out. (RTFM)
var.deep_find_all(:version)1
var = {:status=>0, :value=>{:build=>{:version=>"1.4.8", :revision=>"c8179bd8352d3c62d98fa58b324491230df9342a"}, :build2=>{:version=>"1.4.9", :revision=>"c8179bd8352d3c6"}}}
"1.4.9"