hexorx/countries — pull request #178 by gauthier-delacroix (2014-09-12 13:55:23+00:00)
Title: Fix mongoid field behavior

Current mongoid Country field type behavior makes invalid country values raise a `BadMongoidTypeError` exception on assignation.
This is not the behavior of other Mongoid types ; actually `BadMongoidTypeError` error only exists in this country gem...
When you assign invalid values on base Mongoid types, like `Integer`, no exception is raised. The value is just set to the closest approximation: an integer field is just set to zero when assigning a string.

This PR brings this standard behavior to the Country field: when an invalid value is assigned, the field is set to `nil`, with no exception.

If you want to ensure the validity of the field content, just validate the field presence: if it's not empty, then it's a valid country !