you should use the Options class as a mixin and the setOptions to do the merge properly:
var tclass = new Class({
Implements: [Options],
initialize: function(n) {
this.setOptions(n);
},
get: function() {
return this.options.name;
}
});
var a = new tclass({
name: 'a'
});
var b = new tclass({
name: 'b'
});
alert(a.get()); // a
having said that, in your example i get a different response - as expected - but via $merge and not extend (merge does unlink):
http://www.jsfiddle.net/dimitar/cqd8P/
yet what's the point in this as you have no this.options that exists (you need to pass on an object to extend it / merge it with another one). you may as well just do:
this.options = {
name: n
};
you really want this.setOptions
p.s. for mootools 1.11 Implements is done differently:
var tclass = new Class({
initialize: function(n) {
this.setOptions(n);
},
get: function() {
return this.options.name;
}
});
tclass.implement(new Options);
var a = new tclass({
name: 'a'
});
var b = new tclass({
name: 'b'
});
alert(a.get()); // a