Class: Yes::Core::ActiveJobSerializers::CommandGroupSerializer

Inherits:
ActiveJob::Serializers::ObjectSerializer
  • Object
show all
Defined in:
lib/yes/core/active_job_serializers/command_group_serializer.rb

Overview

ActiveJob serializer for CommandGroup objects.

Instance Method Summary collapse

Instance Method Details

#deserialize(hash) ⇒ Yes::Core::Commands::Group

Returns the deserialized command group.

Parameters:

  • hash (Hash)

    the serialized representation

Returns:



22
23
24
25
# File 'lib/yes/core/active_job_serializers/command_group_serializer.rb', line 22

def deserialize(hash)
  symbolized_hash = hash.deep_symbolize_keys
  Object.const_get(symbolized_hash[:_type]).new(symbolized_hash.except(:_aj_serialized, :_type))
end

#serialize(command_group) ⇒ Hash

Returns the serialized representation.

Parameters:

Returns:

  • (Hash)

    the serialized representation



16
17
18
# File 'lib/yes/core/active_job_serializers/command_group_serializer.rb', line 16

def serialize(command_group)
  super(command_group.to_h.merge(_type: command_group.class.name))
end

#serialize?(argument) ⇒ Boolean

Returns true if the argument can be serialized.

Parameters:

  • argument (Object)

    the argument to check

Returns:

  • (Boolean)

    true if the argument can be serialized



10
11
12
# File 'lib/yes/core/active_job_serializers/command_group_serializer.rb', line 10

def serialize?(argument)
  argument.is_a? Yes::Core::Commands::Group
end