Convert enum values in read attribute

Fix for issue #16459 and issue #14017 
class Post < ActiveRecord::Base
  enum status: [:live, :inactive, :deleted]
end

post = Post.new(:status => :live)
post.status # => "live"

The following are some of the changes after fix

# Before:
<code>post.attributes = {"id"=>1, "post"=>nil, "status"=> 0}</code>
# After : 
<code>post.attributes = {"id"=>1, "post"=>nil, "status"=> "live"}</code>

# Before:
<code>post[:status] = 0</code>
# After : 
<code>post[:status] = "live"</code>

# Before:
<code>post["status"] = 0</code>
# After : 
<code>post["status"] = "live"</code>

# Before:
<code>Post.first => Post id: 1, post: nil, status: 0,created_at: "2014-09-05 18:22:20", updated_at: "2014-09-05 18:22:20"</code>
# After:
<code>Post.first => Post id: 1, post: nil, status: "live" ,created_at: "2014-09-05 18:22:20", updated_at: "2014-09-05 18:22:20"</code>

I have to admit that I'm not really familiar with the enums code.

Can't this whole nested `if` clause:
```ruby
if defined_enums.keys.include?(attr_name)
  if defined_enums[attr_name].has_value?(read_attribute)
    read_attribute = defined_enums[attr_name].key(read_attribute)
  end
end
```

be collapsed into something like this:
```ruby
defined_enum = defined_enums[attr_name]
if defined_enum
  read_attribute = defined_enum.key(read_attribute)
end
```

(what I'm interested in, is that there is only a single Hash lookup on `defined_enums`).