Skip to content

Instantly share code, notes, and snippets.

@bherrmann7
Created June 23, 2010 01:55
Show Gist options
  • Save bherrmann7/449376 to your computer and use it in GitHub Desktop.
Save bherrmann7/449376 to your computer and use it in GitHub Desktop.
// assert schema2hibernate('take_this') == 'takeThis'
def schema2hibernate = { table_name ->
boolean lastUnder = false
table_name.collect {
if( it == '_' ){
lastUnder = true
return ''
}
if (lastUnder) {
lastUnder = false
return it.toUpperCase()
}
it
}.join('')
}
assert schema2hibernate('take_this') == 'takeThis'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment