documentcloud/backbone — pull request #1250 by dgrabov (2012-04-26 12:11:57+00:00)
Title: Add getters and setters

I've created two properties, getters and setters in the Model. These can have functions added to them with the same names as attribute properties and will be called when either get or set is executed. A getter function receives the current attribute value as argument and a setter function receives the attribute value being set as argument. Essentially, the purpose of these is allow get or set calls to be intercepted and manipulate the values prior to execution. In addition, getters can be used to retrieve values that are generated rather than stored, for example: this.get('name') can be used to return a concatenation of first-name and last-name without a stored name attribute.