lib/looksist/hashed.rb in looksist-0.3.7 vs lib/looksist/hashed.rb in looksist-0.3.8

- old
+ new

@@ -106,17 +106,21 @@ all_values = opts.each_with_object({}) do |opt, acc| entity_name = __entity__(opt[:bucket_name] || opt[:using]) modified_array = if at.nil? array_of_hashes.map(&:values) else - json_path = JsonPath.new("#{at}..#{opt[:using]}") - json_path.on(array_of_hashes.to_json) + extract_values(array_of_hashes, opt[:using]) end keys = modified_array.flatten.compact.uniq values = Hash[keys.zip(Looksist.redis_service.send("#{entity_name}_for", keys))] acc[opt[:using]] = values end smart_lookup(array_of_hashes, opts, all_values, at) + end + + def extract_values(array_of_hashes, using) + hash = array_of_hashes.is_a?(Array) ? {:root => array_of_hashes} : array_of_hashes + hash.find_all_values_for(using) end def smart_lookup(array_of_hashes, opts, all_values, at) ## populate is not a array array_of_hashes.collect do |elt|