beerlington/classy_enum — pull request #42 by jpterry (2014-09-30 23:04:59+00:00)
Title: Return nil when enum set to nil through active record

Hello,

I like this gem a lot, but I ran into issues when migrating existing code to use it.
It was surprising that the following code didn't work
```ruby
obj_with_enum = SomeModel.new(:enum_field => nil)
unless obj_with_enum.enum_field
# This seems like it should be executed, but isn't because enum_field returns an instance of an anonymous proxy class.
# Ensuring every caller checks for .nil? isn't acceptable since ruby practices equate nil and falsy.
end
```
So to fix, I altered `ClassyEnum::Base#build` to return proper nil when passed nil as the value. Since this method is called with the return from read_attribute, and read_attribute returns nil when the attribute is set to nil, this seemed like the right place to do it.