Skip to content

Instantly share code, notes, and snippets.

@lonniev
Last active August 29, 2015 14:23
Show Gist options
  • Save lonniev/101834b8790b25f46c78 to your computer and use it in GitHub Desktop.
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
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