Skip to content

Instantly share code, notes, and snippets.

@simonask
Created January 10, 2009 14:18
Show Gist options
  • Save simonask/45459 to your computer and use it in GitHub Desktop.
Save simonask/45459 to your computer and use it in GitHub Desktop.
MyBase: class {
.some_method: (a) {
return a + 2
}
}
MyObject: class {
.prototype: MyBase
// Method 1
.old_some_method: .some_method
.some_method: (a) {
return .old_some_method(a) + 2
}
// Method 2
.some_method: (a) {
old: .prototype.&some_method
return old(a) + 2
}
}
// Monkeypatch it!
old: MyObject.&some_method
MyObject.some_method: (a) {
old(a)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment