Skip to content

Commit c0765cd

Browse files
committed
add Collection.prototype.clone method
1 parent e863afe commit c0765cd

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

dist/hook.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* https://github.com/doubleleft/hook-javascript
44
*
55
* @copyright 2015 Doubleleft
6-
* @build 1/26/2015
6+
* @build 2/10/2015
77
*/
88
(function(window) {
99
//
@@ -11162,6 +11162,26 @@ Hook.Collection.prototype.buildQuery = function() {
1116211162
return query;
1116311163
};
1116411164

11165+
/**
11166+
* Return a new copy of the collection.
11167+
* @method clone
11168+
* @return {Collection}
11169+
*/
11170+
Hook.Collection.prototype.clone = function() {
11171+
var clone = this.client.collection(this.name);
11172+
11173+
// copy attributes to the new instance
11174+
clone.options = _.clone(this.options);
11175+
clone.wheres = _.clone(this.wheres);
11176+
clone.ordering = _.clone(this.ordering);
11177+
clone._group = _.clone(this._group);
11178+
clone._limit = _.clone(this._limit);
11179+
clone._offset = _.clone(this._offset);
11180+
clone._remember = _.clone(this._remember);
11181+
11182+
return clone;
11183+
};
11184+
1116511185
/**
1116611186
* module Hook
1116711187
* class Hook.CollectionItem

0 commit comments

Comments
 (0)