Skip to content

Commit

Permalink
added ability to inherit from other factories
Browse files Browse the repository at this point in the history
  • Loading branch information
mkuklis committed Oct 9, 2012
1 parent 1273f12 commit 0551b18
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/rosie.js
Expand Up @@ -34,6 +34,16 @@ Factory.prototype = {
build: function(attrs) { build: function(attrs) {
var result = this.attributes(attrs); var result = this.attributes(attrs);
return this.construct ? new this.construct(result) : result; 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;
} }
}; };


Expand Down

0 comments on commit 0551b18

Please sign in to comment.