Skip to content

Commit

Permalink
add Collection.prototype.clone method
Browse files Browse the repository at this point in the history
  • Loading branch information
endel committed Feb 10, 2015
1 parent e863afe commit c0765cd
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
22 changes: 21 additions & 1 deletion dist/hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* https://github.com/doubleleft/hook-javascript
*
* @copyright 2015 Doubleleft
* @build 1/26/2015
* @build 2/10/2015
*/
(function(window) {
//
Expand Down Expand Up @@ -11162,6 +11162,26 @@ Hook.Collection.prototype.buildQuery = function() {
return query;
};

/**
* Return a new copy of the collection.
* @method clone
* @return {Collection}
*/
Hook.Collection.prototype.clone = function() {
var clone = this.client.collection(this.name);

// copy attributes to the new instance
clone.options = _.clone(this.options);
clone.wheres = _.clone(this.wheres);
clone.ordering = _.clone(this.ordering);
clone._group = _.clone(this._group);
clone._limit = _.clone(this._limit);
clone._offset = _.clone(this._offset);
clone._remember = _.clone(this._remember);

return clone;
};

/**
* module Hook
* class Hook.CollectionItem
Expand Down
Loading

0 comments on commit c0765cd

Please sign in to comment.