lib/zencoder/extensions.rb in zencoder-2.1.13 vs lib/zencoder/extensions.rb in zencoder-2.1.14
- old
+ new
@@ -1,11 +1,27 @@
class Hash
def recursive_with_indifferent_access
hash = with_indifferent_access
+
hash.each do |key, value|
- if value.is_a?(Hash)
+ if value.is_a?(Hash) || value.is_a?(Array)
hash[key] = value.recursive_with_indifferent_access
end
end
- return hash
+
+ hash
+ end
+end
+
+class Array
+ def recursive_with_indifferent_access
+ array = dup
+
+ array.each_with_index do |value, index|
+ if value.is_a?(Hash) || value.is_a?(Array)
+ array[index] = value.recursive_with_indifferent_access
+ end
+ end
+
+ array
end
end