Last active
August 29, 2015 14:23
-
-
Save lonniev/101834b8790b25f46c78 to your computer and use it in GitHub Desktop.
Given a nested hash, serialize that to an array of property key=value pairs where each key is the dotted form of all the hash keys to reach the value
This file contains hidden or 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 serialize( h ) | |
h.collect{ |k,v| | |
unless v.kind_of? Hash | |
"#{k}=#{v}" | |
else | |
serialize( v ).collect{ |more| "#{k}.#{more}" } | |
end | |
}.flatten | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment