Last active
August 29, 2015 14:02
-
-
Save jordaaash/6827b1b3653914049c64 to your computer and use it in GitHub Desktop.
Bookshelf.js: camelize and underscore columns
This file contains 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
parse: (attributes) -> | |
_.reduce attributes, (object, value, key) -> | |
camelized = _str.camelize(key) | |
object[camelized] = value | |
object | |
, {} | |
format: (attributes) -> | |
_.reduce attributes, (object, value, key) -> | |
underscored = _str.underscored(key) | |
object[underscored] = value | |
object | |
, {} | |
toJSON: (options) -> | |
json = super(options) | |
@format(json) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment