Browse files

Call setter if it exists on create.

  • Loading branch information...
1 parent 6cc0fd2 commit bc9962bd748773c57806856c70f33f1ae79b22cc @jwall committed Feb 10, 2012
Showing with 8 additions and 0 deletions.
  1. +8 −0 lib/abstract-class.js
View
8 lib/abstract-class.js
@@ -133,6 +133,14 @@ AbstractClass.create = function (data, callback) {
create();
} else {
obj = new this(data);
+
+ // Call setter if it exists on create
+ Object.keys(data).forEach( function (key) {
+ if (obj.constructor.setter && obj.constructor.setter[key]) {
+ obj.constructor.setter[key].call(obj, obj[key]);
+ }
+ }.bind(obj));
+)
data = obj.toObject(true);
// validation required

0 comments on commit bc9962b

Please sign in to comment.