fix(ngResource): resource instances should be instantiated with the corr...

### The problem
Consider a simple Resource 'class' with a custom method added to the prototype:
```js
var User = $resource('/user/:userId', {userId:'@id'});
User.prototype.sayHello = function(){};
```
Then this will work:
```js
var user = new User();
user.sayHi();
```
But when one or more instances are retrieved using `.get()` or `.query()`, the wrong constructor is used, causing this functionality to break:
```js
// When using .get()
var user = User.get({userId:123}, function() {
    user.sayHi(); // This will not work
});

// When using .query()
users = User.query(function(){
    var user = users[0];
    user.sayHi(); // This will not work
});
```
This is a result of instantiating the new resource instances directly from the `Resource` constructor defined in the `resourceFactory()` function and not the constructor of the current Resource 'class'.

### The fix

This PR makes sure the correct constructor is used and the prototype is chained correctly if resource instances are created by `.get()` or `.query()`.

```js
// When using .get()
var user = User.get({userId:123}, function() {
    user.sayHi(); // This will now work as expected
});

// When using .query()
users = User.query(function(){
    var user = users[0];
    user.sayHi(); // This will now work as expected
});
```
This PR replaces and extends #5168 in that it now also includes support for objects instantiated by `query()` and is using a newer version of `ngResource`.