rails-api/active_model_serializers — pull request #744 by TheWudu (2014-12-02 13:57:03+00:00)
Title: Capsulate serializers and enable identifier instead of default id.to_s

This PR contains:
a) Enable use of identifier to override default id.to_s
b) Enable use of own serializer capsulated in modules
c) Enable use of object_type to override default name (including modules)

According a: We need the possibility to define an own identifier, because the nested models are mainly identified by its type and not it's id. With this change the default behaviour is not changed and it is possible to use another content in the links section. ( e.g. { id: xxx, type: yyy } )

According b): We do not have a rails/rails-api structure and the Serializers are inside ::Serializer, and the models are inside ::Model. The original code would expect the serializer to be defined in ::Model::Serializer. This would mix serializer and models.

According c) Because of the modules the type_name would look like "/model/" which looks ugly and does represent the internal structure of the classes, not the content.

We are not really happy with the current solution, because the model has to define the serializer it is used by, but we can't add the "to-use-serializer" to the call, because of the implicit nesting. The object_type method may be moved to the serializer instead of the model.