lib/model.js
function Model(data) {
  var attributes = this.__proto__.constructor.attributes;
  var i, ilen;
  var dirty = false;

  Object.defineProperties(this, {
    _id: {
      configurable: false,
      enumerable: true,
      writable: false,
      value: ++uniqueId
    },
    _isDirty: {
      configurable: false,
      enumerable: true,
      get: function isDirty() {
        return dirty;
      },
      set: function isDirty(d) {
        dirty = d;
        if (!d && this._previousData) {
          this._previousData = undefined;
        }
      }
    },
    _isNew: {
      configurable: false,
      enumerable: true,
      get: function isNewModel() {
        var newModel = false;
        var attrValue;

        if (this._primaryAttributes) {
          for (i = 0, ilen = this._primaryAttributes.length; i < ilen && !newModel; ++i) {
            attrValue = this[this._primaryAttributes[i]];

            if ((attrValue === undefined) || (attrValue === null)) {
              newModel = true;
            }
          }
        }

        return newModel;
      }
    }
  });

  if (attributes) {
    Object.defineProperties(this, attributes);
    Object.defineProperty(this, '_data', {
      configurable: false,
      enumerable: false,
      writable: false,
      value: _defaultData(attributes)
    });
  }

  if (Array.isArray(data)) {
    for (i = 0, ilen = data.length; i < ilen; ++i) {
      if (this._primaryAttributes[i]) {
        this[this._primaryAttributes[i]] = data[i];
      }
    }
  } else if (data) {
    this.fromJSON(data);
  }

  this._isDirty = false; // overwrite...
}
function Model(data) {
  var attributes = this.__proto__.constructor.attributes;
  var i, ilen;
  var dirty = false;

  Object.defineProperties(this, {
    _id: {
      configurable: false,
      enumerable: true,
      writable: false,
      value: ++uniqueId
    },
    _isDirty: {
      configurable: false,
      enumerable: true,
      get: function isDirty() {
        return dirty;
      },
      set: function isDirty(d) {
        dirty = d;
        if (!d && this._previousData) {
          this._previousData = undefined;
        }
      }
    },
    _isNew: {
      configurable: false,
      enumerable: true,
      get: function isNewModel() {
        var newModel = false;
        var attrValue;

        if (this._primaryAttributes) {
          for (i = 0, ilen = this._primaryAttributes.length; i < ilen && !newModel; ++i) {
            attrValue = this[this._primaryAttributes[i]];

            if ((attrValue === undefined) || (attrValue === null)) {
              newModel = true;
            }
          }
        }

        return newModel;
      }
    }
  });

  if (attributes) {
    Object.defineProperties(this, attributes);
    Object.defineProperty(this, '_data', {
      configurable: false,
      enumerable: false,
      writable: false,
      value: _defaultData(attributes)
    });
  }

  if (Array.isArray(data)) {
    for (i = 0, ilen = data.length; i < ilen; ++i) {
      if (this._primaryAttributes[i]) {
        this[this._primaryAttributes[i]] = data[i];
      }
    }
  } else if (data) {
    this.fromJSON(data);
  }

  this._isDirty = false; // overwrite...
}
function Model ( data ) { var attributes = this . __proto__ . constructor . attributes ; var i , ilen ; var dirty = false ; Object . defineProperties ( this , { _id : { configurable : false , enumerable : true , writable : false , value : ++ uniqueId } , _isDirty : { configurable : false , enumerable : true , get : function isDirty ( ) { return dirty ; } , set : function isDirty ( d ) { dirty = d ; if ( ! d && this . _previousData ) { this . _previousData = undefined ; } } } , _isNew : { configurable : false , enumerable : true , get : function isNewModel ( ) { var newModel = false ; var attrValue ; if ( this . _primaryAttributes ) { for ( i = 0 , ilen = this . _primaryAttributes . length ; i < ilen && ! newModel ; ++ i ) { attrValue = this [ this . _primaryAttributes [ i ] ] ; if ( ( attrValue === undefined ) || ( attrValue === null ) ) { newModel = true ; } } } return newModel ; } } } ) ; if ( attributes ) { Object . defineProperties ( this , attributes ) ; Object . defineProperty ( this , '_data' , { configurable : false , enumerable : false , writable : false , value : _defaultData ( attributes ) } ) ; } if ( Array . isArray ( data ) ) { for ( i = 0 , ilen = data . length ; i < ilen ; ++ i ) { if ( this . _primaryAttributes [ i ] ) { this [ this . _primaryAttributes [ i ] ] = data [ i ] ; } } } else if ( data ) { this . fromJSON ( data ) ; } this . _isDirty = false ; // overwrite... }
Base Model function constructor

@param {Object} data      the model data
Base Model function constructor