Skip to content

Instantly share code, notes, and snippets.

@ryandotsmith
Created December 7, 2013 00:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryandotsmith/7835702 to your computer and use it in GitHub Desktop.
Save ryandotsmith/7835702 to your computer and use it in GitHub Desktop.
Snake to camel
def s2c(x)
case x
when Hash then Hash[*x.flatten(1).map{|x| s2s(x)}]
when Array then x.map{|x| s2s(x)}
when Symbol then String(x).camelcase
else x
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment