EventedMind/iron-router — pull request #280 by jagi (2013-11-06 14:58:04+00:00)
Title: Fixed error when collecting parent hooks

Child controller inherits prototype's methods from the parent controller prototype.

So, if we have `Parent` controller

```js
Parent.prototype.before = function () {
console.log('parent.before');
};
```

and we create `Child` class inheriting from the `Parent` we will have prototype as follows:

```js
Child.prototype.before = function () {
console.log('parent.before');
};
```

Now when collecting hooks, the result hooks array will contain both functions instead one and it will cause double hook execution.

The solution is not copying Parent prototype to Child prototype or take that into account when hooks are run. I chose second solution because it's less invasive.

Before concatenating arrays of hooks with parent class first I check if parent hooks are not the same as hooks in current class.

```js
if (ctor.__super__ && (ctor.prototype[hookName] !== ctor.__super__.constructor.prototype[hookName])) {
hooks = hooks.concat(collectInheritedHooks(ctor.__super__.constructor));
}
```