Created
October 13, 2015 21:48
-
-
Save hxegon/3637b539dc8fb11ed5d6 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 map_product_strings(prod_val, &block) | |
# product hash -> product hash with strings changed through block | |
case prod_val | |
when Hash | |
Hash[prod_val.map {|key, val| [key, map_product_strings(val, &block)]}] | |
when Array | |
prod_val.map { |v| map_product_strings(v, &block) } | |
when String | |
yield prod_val | |
else | |
prod_val | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment