Class: EQ::Job

Inherits:
Struct
  • Object
show all
Defined in:
lib/eq/job.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



2
3
4
# File 'lib/eq/job.rb', line 2

def id
  @id
end

#serialized_payloadObject

Returns the value of attribute serialized_payload

Returns:

  • (Object)

    the current value of serialized_payload



2
3
4
# File 'lib/eq/job.rb', line 2

def serialized_payload
  @serialized_payload
end

Class Method Details

.dump(*unserialized_payload) ⇒ Object



4
5
6
# File 'lib/eq/job.rb', line 4

def dump *unserialized_payload
  Marshal.dump(unserialized_payload.flatten)
end

.load(id, serialized_payload) ⇒ Object



8
9
10
# File 'lib/eq/job.rb', line 8

def load id, serialized_payload
  Job.new id, serialized_payload
end

Instance Method Details

#performObject

calls MyJobClass.perform(*payload)



20
21
22
23
# File 'lib/eq/job.rb', line 20

def perform
  const, *payload = unpack
  const.perform *payload
end

#unpackObject

unmarshals the serialized_payload



14
15
16
17
# File 'lib/eq/job.rb', line 14

def unpack
  #[const_name.split("::").inject(Kernel){|res,current| res.const_get(current)}, *payload]
  Marshal.load(serialized_payload)
end