Allow model state get and set to be overridden

For models with complex attributes (i.e. nested models or attributes set
to functions) there needs to be a way to specify how the model is serialized
to and deserialized from a state object.

This commit allows model authors to define getState and setState methods
to control the serialization.