Class: Workerholic::JobSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/workerholic/job_serializer.rb

Class Method Summary collapse

Class Method Details

.deserialize(json_job) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/workerholic/job_serializer.rb', line 7

def self.deserialize(json_job)
  job_info = JSON.parse(json_job, symbolize_names: true)

  job_info[:klass] = job_info[:klass] ? Object.const_get(job_info[:klass]) : nil
  job_info[:wrapper] = job_info[:wrapper] ? Object.const_get(job_info[:wrapper]) : nil

  JobWrapper.new(job_info)
end

.deserialize_stats(json_stat) ⇒ Object



16
17
18
# File 'lib/workerholic/job_serializer.rb', line 16

def self.deserialize_stats(json_stat)
  JSON.parse(json_stat, symbolize_names: true)
end

.serialize(job) ⇒ Object



3
4
5
# File 'lib/workerholic/job_serializer.rb', line 3

def self.serialize(job)
  JSON.dump(job.to_hash)
end