title: CoffeeScript: Extend super method like in Rickshaw Prototype example
body: <p>I'm playing with the fantastic <a href="http://code.shutterstock.com/rickshaw/" rel="nofollow">Rickshaw</a> library which uses <a href="https://github.com/shutterstock/rickshaw/blob/master/src/js/Rickshaw.Class.js" rel="nofollow">Prototype's class-based OOP system</a>.  This includes the <code>extend</code> method which allows a sub-class to extend a method in a parent class like this:</p>
  
  <p><a href="https://github.com/shutterstock/rickshaw/blob/master/src/js/Rickshaw.Graph.Renderer.js#L20" rel="nofollow">Parent class</a>:</p>
  
  <pre><code>defaults: function() {
    return {
      tension: 0.8,
      // etc...
    };
  }
  </code></pre>
  
  <p><a href="https://github.com/shutterstock/rickshaw/blob/master/src/js/Rickshaw.Graph.Renderer.Stack.js#L7" rel="nofollow">Sub class</a>:</p>
  
  <pre><code>defaults: function($super) {
    return Rickshaw.extend( $super(), {
      fill: true,
      // etc...
    } );
  }
  </code></pre>
  
  <p>I'm trying to find the syntax to do the same in CoffeeScript, so that CoffeeScript handles the Class inheritance rather than Prototype.  Can you help?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Thanks to @tomahaug's answer I got this working, and I have now realised there is a better way.  While <code>$super</code> is a Prototype feature, <code>extend</code> is actually defined both in <a href="http://github.com/shutterstock/rickshaw/blob/master/src/js/Rickshaw.Class.js#L45-L48" rel="nofollow">Prototype</a> and the <a href="https://github.com/shutterstock/rickshaw/blob/master/src/js/Rickshaw.js#L23-L29" rel="nofollow">Rickshaw</a> top-level object, like this:</p>
  
  <pre><code>extend: (destination, source) -&gt;
    for property of source
      if (source.hasOwnProperty(property))
        destination[property] = source[property]
    destination
  </code></pre>
  
  <p>So making use of this method, the solution looks like this:</p>
  
  <pre><code>defaults: () -&gt;
    Rickshaw.extend super(), 
      fill: true,
      // etc...
  </code></pre>
  
  <p>So the only way this could be improved another step is if it turns out that this is built into CoffeeScript in some way.</p>