Skip to content

Instantly share code, notes, and snippets.

@ryansmith3136
Created December 7, 2013 00:40
Show Gist options
  • Select an option

  • Save ryansmith3136/7835702 to your computer and use it in GitHub Desktop.

Select an option

Save ryansmith3136/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