title: Initialising an object with dynamic name - coffeescript/node.js/javaScript
body: <p>I am attempting to build a plugin system where I do not know the plugins beforehand. Initialising an object using 'require' from browserify. As follows:</p>
  
  <pre><code>class.coffee:
  
     class MyClass
      name: "my-class"
      constructor: -&gt;
  
      @getName: -&gt;
          return @name
  
    exports.plugin = new MyClass
  </code></pre>
  
  <p>Then from the calling file I have:</p>
  
  <pre><code>pluginName = # from a config file
  { plugin } = require './#{pluginName}.coffee'
  console.log plugin
  console.log plugin.getName()
  </code></pre>
  
  <p>The first logger call gives me:</p>
  
  <pre><code>MyClass{ name="my-class" }
  </code></pre>
  
  <p>The second one fails however with plugin.getName is not a function.</p>
  
  <p>Any help/guidance appreciated. I'm not a JS developer and am new to coffeescript/node.js as well.</p>
  
  <p>Thanks.</p>