[BAC-336] Move AJ serializer to AME from voices - #17
Merged
Conversation
HolyWalley
marked this pull request as ready for review
July 8, 2025 10:53
There was a problem hiding this comment.
Pull Request Overview
This PR introduces support for serializing ActiveModel::Entity objects in ActiveJob, integrates the serializer via a Railtie, and adds a round-trip serialization spec.
- Add
ActiveModelSerializerunderActiveJob::Serializersto handle Entity serialization/deserialization. - Register the serializer through a new Railtie initializer when Rails and ActiveJob are present.
- Add a spec to verify that an Entity instance can be serialized and deserialized via
ActiveJob::Arguments. - Declare the
activejobgem dependency in the Gemfile.
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| spec/active_model/entity/active_job_spec.rb | New spec verifying round-trip serialization of an Entity instance. |
| lib/active_model/entity/railtie.rb | Railtie initializer to register the Entity serializer with ActiveJob. |
| lib/active_model/entity/active_job.rb | Implementation of ActiveModelSerializer for ActiveModel::Entity. |
| lib/active_model/entity.rb | Conditional load of the Railtie when Rails is detected. |
| Gemfile | Adds activejob gem to enable ActiveJob integration. |
Comments suppressed due to low confidence (1)
lib/active_model/entity/railtie.rb:7
- Consider adding a spec to verify that the Railtie actually registers
ActiveModelSerializerinRails.application.config.active_job.custom_serializerswhen Rails and ActiveJob are loaded.
initializer "activemodel_entity.configure_active_job_serializer" do
|
|
||
| if defined?(ActiveJob::Serializers::ActiveModelSerializer) | ||
| Rails.application.config.to_prepare do | ||
| Rails.application.config.active_job.custom_serializers << ActiveJob::Serializers::ActiveModelSerializer |
There was a problem hiding this comment.
To prevent duplicate registrations on each to_prepare run (e.g., in development reloads), guard this with an inclusion check, e.g.: unless config.active_job.custom_serializers.include?(...).
Suggested change
| Rails.application.config.active_job.custom_serializers << ActiveJob::Serializers::ActiveModelSerializer | |
| unless Rails.application.config.active_job.custom_serializers.include?(ActiveJob::Serializers::ActiveModelSerializer) | |
| Rails.application.config.active_job.custom_serializers << ActiveJob::Serializers::ActiveModelSerializer | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.