Skip to content

Instantly share code, notes, and snippets.

@fabiomcosta
Created March 21, 2010 20:38
Show Gist options
  • Save fabiomcosta/339547 to your computer and use it in GitHub Desktop.
Save fabiomcosta/339547 to your computer and use it in GitHub Desktop.
var implement = function(key, value, retain){
if (Class.Mutators.hasOwnProperty(key)){
var mutator = Class.Mutators[key];
value = mutator.call(this, value);
if (value == null) return this;
}
if (typeOf(value) == 'function'){
if (value.$hidden) return this;
this.prototype[key] = (retain) ? value : wrap(this, key, value);
} else {
Object.merge(this.prototype, key, value);
}
return this;
};
...
var extraProperties = ['hasOwnProperty', 'toSource', 'watch', 'unwatch', 'valueOf', 'isPrototypeOf',
'propertyIsEnumerable', 'toLocaleString', 'toString', 'constructor'];
for(var i in {toString: 1}){ extraProperties = []; break; };
Class.implement({implement: function(object){
for (var key in object) implement.call(this, key, object[key]);
for (var i = extraProperties.length, name; i--;){
name = extraProperties[i];
if(object.hasOwnProperty(name)) implement.call(this, name, object[name]);
}
return this;
}});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment