coffee-script-model
v1.0.2
Published
A simple wrapper over the coffee-script class with getters, setters, fields, and event bindings
Downloads
9
Maintainers
Readme
coffee-script-model
A simple wrapper over the coffee-script class with getters, setters, fields, and event bindings
npm install coffee-script-model --save
Example
Model = require 'coffee-script-model'
class Person extends Model
@property 'firstName'
@property 'lastName'
@property 'fullName',
get: -> "#{@firstName} #{@lastName}"
set: (name) -> [@firstName, @lastName] = name.split ' '
@property 'username'
@property 'sick', default: false
person = new Person firstName: 'bob', lastName: 'smith'
console.log person.fullName
# 'bob smith'
person.fullName = 'thomas vi'
console.log person.firstName
# 'thomas'
See example.coffee for more examples.
Supports
- Node
- Modern browsers
- IE 9+