Skip to content

Instantly share code, notes, and snippets.

@maccman
Created July 28, 2012 17:47
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maccman/3194153 to your computer and use it in GitHub Desktop.
Save maccman/3194153 to your computer and use it in GitHub Desktop.
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
@andreypopp
Copy link

If @url is a param to Spine.Model.Ajax mixin why not just pass it directly:

...
@extend new Spine.Model.Ajax(url: '/charges')
...

@gr2m
Copy link

gr2m commented Jul 29, 2012

Love the @key syntax!

@jamiter
Copy link

jamiter commented Jul 30, 2012

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