Created
June 30, 2010 17:07
-
-
Save thejefflarson/458950 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
| // The primary function of a **Model** is to manipulate and query data. For example filtering | |
| // an array-type object should happen in a subclass of Model. Another great candidate | |
| // for a **Model** is any object that requires an external resource such as an ajax call. | |
| // | |
| // Basically, any long running or long blocking operation should happen in a model. | |
| // **Models** are usually encapsulated in **Views** and rarely, if ever, stand alone. | |
| propublica.Model = Base.extend({ | |
| // The **init** method copies the passed in attributes to the instance's built in | |
| // **_attrs** object. | |
| init : function(attrs){ | |
| this._attrs = this._attrs || {}; | |
| _.extend(this._attrs, attrs); | |
| return this; | |
| }, | |
| // The **copy** method returns a copy of the current **Model** with the instance's | |
| // attributes filled in. | |
| copy : function(){ | |
| return new (this.init)(this._attrs); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment