object attributes to hash and back