Skip to content

Commit 371f9ad

Browse files
authored
Merge pull request rails#53192 from stevepolitodesign/sp-update-serializers-guidance
Guides: Update serialization section [ci skip]
2 parents aea18ea + 811f285 commit 371f9ad

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

guides/source/active_job_basics.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -600,11 +600,6 @@ You can extend the list of supported argument types. You just need to define you
600600
```ruby
601601
# app/serializers/money_serializer.rb
602602
class MoneySerializer < ActiveJob::Serializers::ObjectSerializer
603-
# Checks if an argument should be serialized by this serializer.
604-
def serialize?(argument)
605-
argument.is_a? Money
606-
end
607-
608603
# Converts an object to a simpler representative using supported object types.
609604
# The recommended representative is a Hash with a specific key. Keys can be of basic types only.
610605
# You should call `super` to add the custom serializer type to the hash.
@@ -619,6 +614,12 @@ class MoneySerializer < ActiveJob::Serializers::ObjectSerializer
619614
def deserialize(hash)
620615
Money.new(hash["amount"], hash["currency"])
621616
end
617+
618+
private
619+
# Checks if an argument should be serialized by this serializer.
620+
def klass
621+
Money
622+
end
622623
end
623624
```
624625

0 commit comments

Comments
 (0)