backbone.nested-types
Advanced tools
Comparing version 0.9.0 to 0.9.1
@@ -1,2 +0,2 @@ | ||
// Backbone.nestedTypes 0.9.0 (https://github.com/Volicon/backbone.nestedTypes) | ||
// Backbone.nestedTypes 0.9.1 (https://github.com/Volicon/backbone.nestedTypes) | ||
// (c) 2014 Vlad Balin & Volicon, may be freely distributed under the MIT license | ||
@@ -93,2 +93,6 @@ | ||
create : function(){ | ||
return new this.type(); | ||
}, | ||
property : function( name ){ | ||
@@ -111,8 +115,3 @@ return { | ||
_.extend( this, spec ); | ||
return this; | ||
}, | ||
initialize : function( spec ){ | ||
_.extend( this, spec ); | ||
if( spec.get || spec.set ){ | ||
@@ -135,2 +134,8 @@ // inline property override... | ||
} | ||
return this; | ||
}, | ||
initialize : function( spec ){ | ||
this.options( spec ); | ||
} | ||
@@ -261,2 +266,6 @@ },{ | ||
exports.options.Type.extend({ | ||
create : function(){ | ||
return this.type(); | ||
}, | ||
cast : function( value ){ | ||
@@ -434,3 +443,3 @@ return value == null ? null : this.type( value ); | ||
var defaults = _.defaults( spec.defaults || {}, Base.prototype.__defaults ), | ||
var defaults = _.defaults( spec.defaults || spec.attributes || {}, Base.prototype.__defaults ), | ||
idAttrName = spec.idAttribute || Base.prototype.idAttribute, | ||
@@ -459,3 +468,3 @@ attributes = {}; | ||
return _.extend( _.omit( spec, 'collection' ), { | ||
return _.extend( _.omit( spec, 'collection', 'attributes' ), { | ||
__defaults : defaults, // needed for attributes inheritance | ||
@@ -494,3 +503,3 @@ __attributes : attributes | ||
else{ | ||
attr.type && ( init[ name ] = attr.type ); | ||
attr.type && ( init[ name ] = attr ); | ||
} | ||
@@ -507,3 +516,3 @@ }); | ||
for( var name in init ){ | ||
defaults[ name ] = new init[ name ](); | ||
defaults[ name ] = init[ name ].create(); | ||
} | ||
@@ -741,3 +750,3 @@ | ||
isResolved : false, | ||
resolvedWith : null, | ||
@@ -754,3 +763,3 @@ toJSON : function(){ | ||
var idName = this.model.prototype.idAttribute; | ||
this.isResolved = false; | ||
this.resolvedWith = null; | ||
@@ -764,3 +773,5 @@ return _.map( raw, function( id ){ | ||
toggle : function( model ){ | ||
toggle : function( modelOrId ){ | ||
var model = this.resolvedWith.get( modelOrId ); | ||
if( this.get( model ) ){ | ||
@@ -790,3 +801,3 @@ this.remove( model ); | ||
this.reset( _.compact( values ), { silent : true } ); | ||
this.isResolved = true; | ||
this.resolvedWith = collection; | ||
@@ -807,3 +818,3 @@ return this; | ||
if( !refs.isResolved ){ | ||
if( !refs.resolvedWith ){ | ||
var master = getMaster.call( this ); | ||
@@ -810,0 +821,0 @@ master && master.length && refs.resolve( master ); |
@@ -21,3 +21,3 @@ { | ||
"license": "MIT", | ||
"version": "0.9.0" | ||
"version": "0.9.1" | ||
} |
@@ -1,2 +0,2 @@ | ||
IMPORTANT. There changes in verion 9.x which is not compatible with previous versions. Following changes in code will be required: | ||
IMPORTANT. There are changes in verion 9.x breaking compatibility with previous versions. Following changes in your code are required: | ||
- NestedTypes.Attribute({ ... }) -> NestedTypes.options({ ... }) | ||
@@ -33,3 +33,3 @@ - NestedTypes.Attribute( Type, value ) -> Type.value( value ) | ||
defaults : { | ||
attributes : { | ||
// Primitive types | ||
@@ -106,7 +106,8 @@ login : String, // = "" | ||
### Model.defaults: | ||
- Models.attributes as an alternative to 'defaults' | ||
- Native properties are created for every entry. | ||
- Entries are inherited from the base Model.defaults. | ||
- Entries are inherited from the base Model.defaults/attributes. | ||
- JSON literals will be deep copied upon creation of model. | ||
- defaults *must* be an object, functions are not supported. | ||
- attributes *must* be declared in defaults. | ||
- defaults/attributes *must* be an object, functions are not supported. | ||
- attributes *must* be declared in defaults/attributes. | ||
@@ -122,3 +123,3 @@ | ||
var DetailedUserInfo = UserInfo.extend({ | ||
defaults : { | ||
attributes : { // <- the same as 'defaults', use whatever you like | ||
login : '', | ||
@@ -125,0 +126,0 @@ roles : [ 'user' ] |
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
48062
648
552