Class: ActiveJob::Serializers::ObjectSerializer
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
ActiveJob::Serializers::BigDecimalSerializer, ActiveJob::Serializers::DateSerializer, ActiveJob::Serializers::DateTimeSerializer, ActiveJob::Serializers::DurationSerializer, ActiveJob::Serializers::ModuleSerializer, RangeSerializer, ActiveJob::Serializers::SymbolSerializer, ActiveJob::Serializers::TimeObjectSerializer, ActiveJob::Serializers::TimeSerializer, ActiveJob::Serializers::TimeWithZoneSerializer
|
|
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
::Singleton
|
|
Inherits: | Object |
Defined in: | activejob/lib/active_job/serializers/object_serializer.rb |
Overview
::ActiveJob::Base
class for serializing and deserializing custom objects.
Example:
class MoneySerializer < ActiveJob::Serializers::ObjectSerializer
def serialize(money)
super("amount" => money.amount, "currency" => money.currency)
end
def deserialize(hash)
Money.new(hash["amount"], hash["currency"])
end
private
def klass
Money
end
end
Instance Attribute Summary
-
#deserialize(json)
readonly
Deserializes an argument from a JSON primitive type.
-
#serialize?(argument) ⇒ Boolean
readonly
Determines if an argument should be serialized by a serializer.
::Singleton
- Included
#duplicable? |
|
Instance Method Summary
-
#serialize(hash)
readonly
Serializes an argument to a JSON primitive type.
-
#klass
private
The class of the object that will be serialized.
Instance Attribute Details
#deserialize(json) (readonly)
Deserializes an argument from a JSON primitive type.
# File 'activejob/lib/active_job/serializers/object_serializer.rb', line 44
delegate :serialize?, :serialize, :deserialize, to: :instance
#serialize?(argument) ⇒ Boolean
(readonly)
Determines if an argument should be serialized by a serializer.
# File 'activejob/lib/active_job/serializers/object_serializer.rb', line 34
delegate :serialize?, :serialize, :deserialize, to: :instance
Instance Method Details
#klass (private)
The class of the object that will be serialized.
# File 'activejob/lib/active_job/serializers/object_serializer.rb', line 50
def klass # :doc: raise NotImplementedError end
#serialize(hash) (readonly)
Serializes an argument to a JSON primitive type.
# File 'activejob/lib/active_job/serializers/object_serializer.rb', line 39
delegate :serialize?, :serialize, :deserialize, to: :instance