inherit-model
A simple Backbone-inspired model wrapper for the npm inherit
package
Why?
- Universal getter and setter methods
get
andset
. Don't have 100s of getters and setters. - Don't accidentally set properties of classes that aren't defined again. Fields are strict.
- Simple
toJSON
. - Easy default fields.
- Keeps things lightweight.
Example
inherit = require 'inherit'Model = require 'inherit-model' User = inherit Model : # Set the field names permanently @fields username: undefined friendIds: # Call the super class (DON'T FORGET!!!) @__baseparams user = username: 'grant'userset 'username''gdawg' consolelog usertoJSON # {username: 'gdawg', friendIds: []}
See the tests for more exampless.
Install
npm install inherit-model --save