Permalink
Browse files

added ability to inherit from other factories

  • Loading branch information...
1 parent 1273f12 commit 0551b18a61f3b0bd9963d10746d15299382c3adf @mkuklis mkuklis committed Oct 9, 2012
Showing with 10 additions and 0 deletions.
  1. +10 −0 src/rosie.js
View
10 src/rosie.js
@@ -34,6 +34,16 @@ Factory.prototype = {
build: function(attrs) {
var result = this.attributes(attrs);
return this.construct ? new this.construct(result) : result;
+ },
+
+ inherit: function(name) {
+ var factory = Factory.factories[name];
+ for(var attr in factory.attrs) {
+ if(factory.attrs.hasOwnProperty(attr)) {
+ this.attrs[attr] = factory.attrs[attr];
+ }
+ }
+ return this;
}
};

0 comments on commit 0551b18

Please sign in to comment.