Module: ActiveModelSerializersPg

Defined in:
lib/active_model_serializers_pg/collection_serializer.rb,
lib/active_model_serializers_pg/version.rb,
lib/generators/active_model_serializers_pg/active_model_serializers_pg_generator.rb

Overview

This is a near-verbatim copy of ActiveModel::Serializer::CollectionSerializer, but we patch the initialize method to avoid loading the ActiveRecord::Relation. It’s still possible to load it if you call each, but we do it lazily. This is based on AMS 0.10.8. For each of updates we mark each of our changes with a PATCHED comment.

It would be nicer to keep this class mostly empty and just delegate to an ActiveModel::Serializer::CollectionSerializer instance when needed, but then we’d still have to instantiate it eventually, any time we proxy a call (not just each), and that materializes the Relation. TODO: Is it possible to replace its initialize class? Or is that too wild even for Ruby?

Defined Under Namespace

Modules: Generators Classes: CollectionSerializer

Constant Summary collapse

VERSION =
'0.2.0'