Add as_hashref method to the user object.