write_attribute should return a type casted value

write_attribute currently doesn't return the type casted value.  

See this gist:

https://gist.github.com/smtlaissezfaire/e57dfaa90f87d9de7fa9