From 6b433bcee0791efd2f2def4f252f0c4a368f9a4c Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 23 Jul 2014 13:05:30 +0200 Subject: [PATCH] Add clone() method to model. --- app/coffee/modules/base/model.coffee | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/coffee/modules/base/model.coffee b/app/coffee/modules/base/model.coffee index a2bae6af..d3e90d95 100644 --- a/app/coffee/modules/base/model.coffee +++ b/app/coffee/modules/base/model.coffee @@ -28,6 +28,12 @@ class Model @.setAttrs(data) @.initialize() + clone: -> + instance = new Model(@._name, @._attrs, @._dataTypes) + instance._modifiedAttrs = @._modifiedAttrs + instance._isModified = @._isModified + return instance + applyCasts: -> for attrName, castName of @._dataTypes castMethod = service.casts[castName]