Created
July 28, 2012 17:47
-
-
Save maccman/3194153 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Spine = require('spine') | |
Accounting = require('accounting') | |
class Charge extends Spine.Model | |
@key 'amount', required: true | |
@key 'description' | |
@key 'token' | |
@key 'status' | |
@key 'outgoing', Boolean | |
@key 'created_at', Date | |
@key 'updated_at', Date | |
@url: '/charges' | |
@extend Spine.Model.Ajax | |
dollarAmount: (value) -> | |
@amount = Accounting.unformat(value) * 100 if value? | |
(@amount or 0) / 100 | |
module.exports = Charge |
Reminds me of mongoose. Like it and I'm curious how this will be further implemented. Validation would become a bit more elegant.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Love the @key syntax!