CoffeeScript: How to instantiate a class with an attributes hash

This may be hard to find in the docs, but if you want CoffeeScript classes that instantiate their properties from a hash of attributes (like ActiveRecord), do it like this:

class User
  constructor: ({ @name, @email }) ->
    # empty contstructor is fine, CoffeeScript will do the magic.

Example:

var batman = new User(name: 'Bruce Wayne', email: 'batman@example.com')
batman.name # => 'Bruce Wayne'
Arne Hartherz