ampersand-state
Advanced tools
Comparing version 0.4.1 to 0.5.0
@@ -33,5 +33,9 @@ var _ = require('underscore'); | ||
typeAttribute: 'modelType', | ||
// can be allow, ignore, reject | ||
extraProperties: 'ignore', | ||
// Get ID of model per configuration. | ||
// Should *always* be how ID is determined by other code. | ||
getId: function () { | ||
@@ -41,2 +45,4 @@ return this[this.idAttribute]; | ||
// Get namespace of model per configuration. | ||
// Should *always* be how namespace is determined by other code. | ||
getNamespace: function () { | ||
@@ -46,3 +52,9 @@ return this[this.namespaceAttribute]; | ||
// stubbed out to be overwritten | ||
// Get type of model per configuration. | ||
// Should *always* be how type is determined by other code. | ||
getType: function () { | ||
return this[this.typeAttribute]; | ||
}, | ||
// Stubbed out to be overwritten | ||
initialize: function () { | ||
@@ -52,3 +64,4 @@ return this; | ||
// backbone compatibility | ||
// Parse can be used remap/restructure/rename incoming properties | ||
// before they are applied to attributes. | ||
parse: function (resp, options) { | ||
@@ -58,3 +71,4 @@ return resp; | ||
// serialize gets props in raw form | ||
// Serialize is the inverse of `parse` it lets you massage data | ||
// on the way out. Before, sending to server, for example. | ||
serialize: function () { | ||
@@ -64,2 +78,5 @@ return this._getAttributes(false, true); | ||
// Main set method used by generated setters/getters and can | ||
// be used directly if you need to pass options or set multiple | ||
// properties at once. | ||
set: function (key, value, options) { | ||
@@ -66,0 +83,0 @@ var self = this; |
{ | ||
"name": "ampersand-state", | ||
"description": "An observable, extensible state object with derived watchable properties.", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"author": "Henrik Joreteg <henrik@andyet.net>", | ||
@@ -42,11 +42,14 @@ "bugs": { | ||
"ie/9..latest", | ||
"firefox/17..latest", | ||
"firefox/nightly", | ||
"chrome/22..latest", | ||
"firefox/16..latest", | ||
"chrome/canary", | ||
"opera/12..latest", | ||
"opera/next", | ||
"safari/5.1..latest", | ||
"opera/11.0..latest", | ||
"iphone/6..latest", | ||
"ipad/6..latest", | ||
"android-browser/latest" | ||
"ipad/6.0..latest", | ||
"iphone/6.0..latest", | ||
"android-browser/4.2..latest" | ||
] | ||
} | ||
} |
@@ -167,2 +167,17 @@ /*jshint expr: true*/ | ||
test('customizable `type` attribute', function (t) { | ||
var FirstModel = State.extend({ | ||
type: 'hello', | ||
typeAttribute: 'type' | ||
}); | ||
var SecondModel = State.extend({ | ||
modelType: 'second' | ||
}); | ||
var first = new FirstModel(); | ||
var second = new SecondModel(); | ||
t.equal(first.getType(), 'hello'); | ||
t.equal(second.getType(), 'second'); | ||
t.end(); | ||
}); | ||
test('instanceof checks should pass for all parents in the chain', function (t) { | ||
@@ -169,0 +184,0 @@ var P1 = Person.extend({}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56017
1345