angular/angular.js — pull request #5168 by jvandemo (2013-11-27 13:43:30+00:00)
Title: Refactor resource instance creation so prototype chain is respected

### The problem:

Consider a CustomResource object:
```
var CustomResource = new Resource();
CustomResource.prototype.someCustomMethod = function(){};
```

Then the following will work:
```
var resource = new CustomResource();
resource.someCustomMethod(); // Works fine
```

But when an resource is instantiated through a non-instance method, the prototype is lost:
```
var resource = CustomerResource.get({id: 1});
resource.someCustomMethod(); // Does not work because prototype is lost
```
This is a result of instantiating the new resource instance object directly from the `Resource` constructor and not the constructor of the current resource object.

### The fix:

This PR fixes the problem and makes sure that the prototype is chained correctly:

```
var CustomResource = new Resource();
CustomResource.prototype.someCustomMethod = function(){};

var resource = new CustomResource();
resource.someCustomMethod(); // Will still work as before

var resource = CustomerResource.get({id: 1});
resource.someCustomMethod(); // Will also work now!
```

A unit test is also included and the full test suite runs fine.