View difference between Paste ID: D2J8zTuy and dYZy4uMy
SHOW: | | - or go back to the newest paste.
1-
function Product(toConvert) {
1+
function makeProduct(toConvert) {
2-
	this.description = '';
2+
	var product = {
3-
	this.name = '';
3+
          description:'',
4-
	this.attribute = [];
4+
          // ...
5-
	this.children = [];
5+
          rules: makeRules({
6-
	this.parents = [];
6+
            onFoo(){ product.x = y; }
7-
        this.rules = makeRules();
7+
          })
8-
			
8+
        };	
9-
	angular.extend(this, toConvert);
9+
	angular.extend(product, toConvert);
10
        return product;
11-
		
11+
12-
angular.extend(Product, {
12+
13-
			
13+
function makeRules(opts){
14-
});
14+
15
		onChange: function() {
16-
function makeRules(){
16+
17
            		opts.onFoo();
18
		},
19
		onInstantiation: function() {
20
			console.log("Applying instantiation rules: ", this);
21
		},
22
		onContextApplication: function(room) {
23
			this.context = room;
24
			console.log("Applying context rules: ", this, room);
25
		},
26
	}
27
};