kdframework/core — pull request #3 by usirin (2014-12-22 09:54:02+00:00)
Title: Include Mixins

This PR tries to achieve the easiest way to handle mixins. Even though it loops over the prototype target object's prototype, it will only happen once for prototype definition.

## Example:

```coffee
class MixinClass

constructor: ->

@john = 'doe'
@baz = 'qux'

sayHello: -> console.log 'Hello World!'

class FooObject extends KDObject

@include MixinClass

constructor: ->

@john = 'brown' # overriding the property coming from MixinClass

foo = new FooObject

foo.sayHello() # => 'Hello World!'
console.log foo.baz # => 'qux'
console.log foo.john # => 'brown'
```

For some cases you don't want to call constructor, but only get the methods from prototype, you can pass `no` as second parameter to the `.include` method.

```coffee
class BarObject

@include MixinClass, no

bar = new BarObject
console.log bar.baz # => undefined
console.log bar.sayHello() # => 'Hello World'
```