Created
March 3, 2010 01:29
-
-
Save bnolan/320196 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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