renamed 'val' to 'to_ruby' so that it is less likely to clash with field names