Class: MassEncryption::BatchSerializer

Inherits:
ActiveJob::Serializers::ObjectSerializer
  • Object
show all
Defined in:
lib/mass_encryption/batch_serializer.rb

Instance Method Summary collapse

Instance Method Details

#deserialize(hash) ⇒ Object



16
17
18
# File 'lib/mass_encryption/batch_serializer.rb', line 16

def deserialize(hash)
  MassEncryption::Batch.new(klass: hash["klass"].constantize, from_id: hash["from_id"], size: hash["size"], track: hash["track"], tracks_count: hash["tracks_count"])
end

#serialize(batch) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/mass_encryption/batch_serializer.rb', line 6

def serialize(batch)
  super(
    "klass" => batch.klass.name,
    "from_id" => batch.from_id,
    "size" => batch.size,
    "track" => batch.track || 0,
    "tracks_count" => batch.tracks_count || 1
  )
end

#serialize?(argument) ⇒ Boolean

Returns:

  • (Boolean)


2
3
4
# File 'lib/mass_encryption/batch_serializer.rb', line 2

def serialize?(argument)
  argument.kind_of?(MassEncryption::Batch)
end