I have a method with an incoming variable, which represents a script.
e.g.
hello.groovy
Foo.init(this)
Foo.groovy
class Foo {
static init(app) {
}
}
What is the best way to add a ton of new functionality to the app
variable in the init method? Basically, I would like to add all the functionality of another object to the app
object.
For instance, if I had another class:
class Bar {
def a() { }
def b() {
}
}
I would like the app
object to basically be a new Bar()
. In JavaScript, this is easy by using the prototype object, but I cannot seem to get it working in groovy. What is the best way to accomplish this? Or should I be doing something differently?