Defines the base of a proxy for a given type.
A instance of Proxied for type T is intended to use the self
member to forward all methods of an new instance of type T to.
This allows for extensions of type T which can inherit a proxied
instance's behavior without needing to override every method of type T.
class Dazzle {
def a: String = "default a"def b: String = "default b"// ...
}
// define a reusable concrete proxy statisfying Dazzle forwarding// all calls to Proxied method selfclass DazzleProxy(val self: Dazzle) extends Dazzle with Proxied[Dazzle] {
def a: String = self.a
def b: String = self.b
}
val bedazzlable = new Dazzle {
// return a new Dazzle with some sizzledef be(sizzle: String): Dazzle = new DazzleProxy(this) {
overridedef b = "%s %s!!!" format(self.b, sizzle)
}
}
val dazzled = bedazzlable.be("dazzled")
dazzled.b // default b dazzled!!!
dazzled.a // default a
Defines the base of a proxy for a given type. A instance of Proxied for type T is intended to use the
self
member to forward all methods of an new instance of type T to. This allows for extensions of type T which can inherit a proxied instance's behavior without needing to override every method of type T.