thedersen/backbone.validation — pull request #226 by flintinatux (2014-05-19 01:22:15+00:00)
Title: Use Object.prototype.hasOwnProperty instead

Sometimes the `hasOwnProperty` property of an object is deleted or overridden by another library. The best solution is to use `hasOwnProperty` from the `Object` prototype, as below ([reference](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty#Example.3A_hasOwnProperty_as_a_property)):
```javascript
var foo = {
hasOwnProperty: function() {
return false;
},
bar: 'Here be dragons'
};

foo.hasOwnProperty('bar'); // always returns false

// Use another Object's hasOwnProperty and call it with 'this' set to foo
({}).hasOwnProperty.call(foo, 'bar'); // true

// It's also possible to use the hasOwnProperty property from the Object property for this purpose
Object.prototype.hasOwnProperty.call(foo, 'bar'); // true
```
I've run into this issue personally when using Backbone.Validation to validate [Bookshelf.js](http://bookshelfjs.org/) models in node. It would throw `TypeError: undefined is not a function` when trying to `flatten` the model's attributes. This change fixes it.

**NOTE:** I ran grunt, and all existing specs pass. I didn't add any new specs, since this is more of a refactor than a bug-fix or new feature.