refactor attribute definition

a simple refactor of attribute definition makes use of the instance
methods read_attribute and write_attribute as a convenience to model
authors defining custom readers and writers (can call read_attribute and
write_attribue as in the style of active record)