Skip to content

Instantly share code, notes, and snippets.

@bnolan
Created March 3, 2010 01:29
Show Gist options
  • Save bnolan/320196 to your computer and use it in GitHub Desktop.
Save bnolan/320196 to your computer and use it in GitHub Desktop.
Initializable = function(sender){
var initialized = false;
sender.isInitialized = function(){
return initialized;
};
sender.setInitialized = function(){
initialized = true;
};
}
Klass = function(){
var priv = 1;
// Mixins
new Initializable(this);
this.getPrivate = function(){
return priv;
}
}
k = new Klass;
assert.ok(k);
assert.equal(1, k.getPrivate());
assert.equal(null, k.priv);
assert.ok(!k.isInitialized());
k.setInitialized();
assert.ok(k.isInitialized());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment