1
0
Fork 0

Foxx: Delegation from Repository to Collection

This also fixes the Doxygen ****
This commit is contained in:
Lucas Dohmen 2013-08-27 12:54:43 +02:00
parent b23138dbae
commit 8418235769
2 changed files with 43 additions and 0 deletions

View File

@ -50,6 +50,31 @@ function RepositorySpec () {
instance = new TestRepository(collection);
assertEqual(instance.test(), "test");
},
testDelegatesToCollection: function () {
var arg = function () {};
[
"remove",
"replace",
"update",
"removeByExample",
"replaceByExample",
"updateByExample",
"all",
"byExample",
"firstExample"
].forEach(function (f) {
var called = false;
collection = function () {};
collection[f] = function (x) {
called = (arg === x);
};
instance = new FoxxRepository(collection);
instance[f](arg);
assertTrue(called);
});
}
};
}

View File

@ -99,6 +99,8 @@ _.extend(Repository.prototype, {
/// @brief See the documentation of collection.
////////////////////////////////////////////////////////////////////////////////
remove: function () {
'use strict';
this.collection.remove.apply(this.collection, arguments);
},
////////////////////////////////////////////////////////////////////////////////
@ -106,6 +108,8 @@ _.extend(Repository.prototype, {
/// @brief See the documentation of collection.
////////////////////////////////////////////////////////////////////////////////
replace: function () {
'use strict';
this.collection.replace.apply(this.collection, arguments);
},
////////////////////////////////////////////////////////////////////////////////
@ -113,6 +117,8 @@ _.extend(Repository.prototype, {
/// @brief See the documentation of collection.
////////////////////////////////////////////////////////////////////////////////
update: function () {
'use strict';
this.collection.update.apply(this.collection, arguments);
},
////////////////////////////////////////////////////////////////////////////////
@ -120,6 +126,8 @@ _.extend(Repository.prototype, {
/// @brief See the documentation of collection.
////////////////////////////////////////////////////////////////////////////////
removeByExample: function () {
'use strict';
this.collection.removeByExample.apply(this.collection, arguments);
},
////////////////////////////////////////////////////////////////////////////////
@ -127,6 +135,8 @@ _.extend(Repository.prototype, {
/// @brief See the documentation of collection.
////////////////////////////////////////////////////////////////////////////////
replaceByExample: function () {
'use strict';
this.collection.replaceByExample.apply(this.collection, arguments);
},
////////////////////////////////////////////////////////////////////////////////
@ -134,6 +144,8 @@ _.extend(Repository.prototype, {
/// @brief See the documentation of collection.
////////////////////////////////////////////////////////////////////////////////
updateByExample: function () {
'use strict';
this.collection.updateByExample.apply(this.collection, arguments);
},
////////////////////////////////////////////////////////////////////////////////
@ -141,6 +153,8 @@ _.extend(Repository.prototype, {
/// @brief See the documentation of collection.
////////////////////////////////////////////////////////////////////////////////
all: function () {
'use strict';
this.collection.all.apply(this.collection, arguments);
},
////////////////////////////////////////////////////////////////////////////////
@ -148,6 +162,8 @@ _.extend(Repository.prototype, {
/// @brief See the documentation of collection.
////////////////////////////////////////////////////////////////////////////////
byExample: function () {
'use strict';
this.collection.byExample.apply(this.collection, arguments);
},
////////////////////////////////////////////////////////////////////////////////
@ -155,6 +171,8 @@ _.extend(Repository.prototype, {
/// @brief See the documentation of collection.
////////////////////////////////////////////////////////////////////////////////
firstExample: function () {
'use strict';
this.collection.firstExample.apply(this.collection, arguments);
}
});