title: Groovy Prototype Object
body: <p>I have a method with an incoming variable, which represents a script.</p>
  
  <p>e.g.  </p>
  
  <p>hello.groovy</p>
  
  <pre><code>Foo.init(this)
  </code></pre>
  
  <p>Foo.groovy</p>
  
  <pre><code>class Foo {
      static init(app) {
  
      }
  }
  </code></pre>
  
  <p>What is the best way to add a ton of new functionality to the <code>app</code> variable in the init method?  Basically, I would like to add all the functionality of another object to the <code>app</code> object.  </p>
  
  <p>For instance, if I had another class:</p>
  
  <pre><code>class Bar {
      def a() { }
  
      def b() {
  
      }
  }
  </code></pre>
  
  <p>I would like the <code>app</code> object to basically be a <code>new Bar()</code>.  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?</p>