lib/mpatch/hash.rb in mpatch-2.8.0 vs lib/mpatch/hash.rb in mpatch-2.8.1
- old
+ new
@@ -108,9 +108,22 @@
end
return tmp_hash
end
+ # Fetch a nested hash value
+ def value_by_keys(*attrs)
+ attr_count = attrs.size
+ current_val = self
+ for i in 0..(attr_count-1)
+ attr_name = attrs[i]
+ return current_val[attr_name] if i == (attr_count-1)
+ return nil if current_val[attr_name].nil?
+ current_val = current_val[attr_name]
+ end
+ return nil
+ end
+
end
end
require File.join 'mpatch','injector'
\ No newline at end of file