Created
September 4, 2013 23:44
-
-
Save svarks/6444289 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def apply_filters!(hash_or_array) | |
case hash_or_array | |
when Array | |
for i in 0 ... hash_or_array.size do | |
apply_filters!(hash_or_array[i]) | |
end | |
when Hash | |
hash_or_array.each do |key, value| | |
next if value.nil? | |
if value.is_a?(Hash) || value.is_a?(Array) | |
apply_filters!(value) | |
else | |
filters.each do |placeholder, pattern| | |
if pattern && key.match(pattern) | |
# require 'pry' | |
# binding.pry | |
hash_or_array[key] = "<#{placeholder}>" | |
end | |
end | |
end | |
end | |
end |
bmarini
commented
Sep 5, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment