Skip to content

Commit

Permalink
Build
Browse files Browse the repository at this point in the history
  • Loading branch information
tanqhnguyen committed Mar 24, 2014
1 parent 62203fe commit 74e3e2e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 48 deletions.
44 changes: 22 additions & 22 deletions build/backbone.supermodel.amd.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,26 @@
}
};

var getRelation = function(obj, attr, value) {
var relation;

if (attr) {
var relations = _.result(obj, 'relations');
relation = relations[attr];
}

if (value && !relation) {
relation = Model;
}

// catch all the weird stuff
if (relation == void 0) {
relation = Model;
}

return relation;
};

// a simple object is an object that does not come from "new"
var isSimpleObject = function(value) {
return Object.getPrototypeOf(Object.getPrototypeOf(value)) === null;
Expand All @@ -94,26 +114,6 @@
unsafeAttributes: [],
name: null, // set name so that children can refer back to

_getRelation: function(attr, value) {
var relation;

if (attr) {
var relations = _.result(this, 'relations');
relation = relations[attr];
}

if (value && !relation) {
relation = Model;
}

// catch all the weird stuff
if (typeof(relation) == 'undefined') {
relation = Model;
}

return relation;
},

_setupBackref: function(instance, options) {
var name = _.result(this, 'name');
// respect the attribute with the same name in relation
Expand Down Expand Up @@ -146,7 +146,7 @@
if (!check) {
// initiate the relationship here
//var relation = Backbone.Model;
var relation = this._getRelation(key, value);
var relation = getRelation(obj, key, value);
var instance = new relation();
obj.attributes[key] = this._setupBackref(instance, options);
}
Expand All @@ -163,7 +163,7 @@
} else {
if (this._valueForCollection(value)) {
// here we need to initiate the collection manually
var _relation = this._getRelation(finalPath, value);
var _relation = getRelation(obj, finalPath, value);

if (_relation.prototype instanceof Backbone.Model) {
// if we dont have the Collection relation for this, use custom Collection
Expand Down
4 changes: 2 additions & 2 deletions build/backbone.supermodel.amd.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 22 additions & 22 deletions build/backbone.supermodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,26 @@ Backbone.SuperModel = (function(_, Backbone){
}
};

var getRelation = function(obj, attr, value) {
var relation;

if (attr) {
var relations = _.result(obj, 'relations');
relation = relations[attr];
}

if (value && !relation) {
relation = Model;
}

// catch all the weird stuff
if (relation == void 0) {
relation = Model;
}

return relation;
};

// a simple object is an object that does not come from "new"
var isSimpleObject = function(value) {
return Object.getPrototypeOf(Object.getPrototypeOf(value)) === null;
Expand All @@ -84,26 +104,6 @@ Backbone.SuperModel = (function(_, Backbone){
unsafeAttributes: [],
name: null, // set name so that children can refer back to

_getRelation: function(attr, value) {
var relation;

if (attr) {
var relations = _.result(this, 'relations');
relation = relations[attr];
}

if (value && !relation) {
relation = Model;
}

// catch all the weird stuff
if (typeof(relation) == 'undefined') {
relation = Model;
}

return relation;
},

_setupBackref: function(instance, options) {
var name = _.result(this, 'name');
// respect the attribute with the same name in relation
Expand Down Expand Up @@ -136,7 +136,7 @@ Backbone.SuperModel = (function(_, Backbone){
if (!check) {
// initiate the relationship here
//var relation = Backbone.Model;
var relation = this._getRelation(key, value);
var relation = getRelation(obj, key, value);
var instance = new relation();
obj.attributes[key] = this._setupBackref(instance, options);
}
Expand All @@ -153,7 +153,7 @@ Backbone.SuperModel = (function(_, Backbone){
} else {
if (this._valueForCollection(value)) {
// here we need to initiate the collection manually
var _relation = this._getRelation(finalPath, value);
var _relation = getRelation(obj, finalPath, value);

if (_relation.prototype instanceof Backbone.Model) {
// if we dont have the Collection relation for this, use custom Collection
Expand Down
4 changes: 2 additions & 2 deletions build/backbone.supermodel.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 74e3e2e

Please sign in to comment.