Class: EQ::Job
- Inherits:
-
Struct
- Object
- Struct
- EQ::Job
- Defined in:
- lib/eq/job.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#serialized_payload ⇒ Object
Returns the value of attribute serialized_payload.
Class Method Summary collapse
Instance Method Summary collapse
-
#perform ⇒ Object
calls MyJobClass.perform(*payload).
-
#unpack ⇒ Object
unmarshals the serialized_payload.
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id
2 3 4 |
# File 'lib/eq/job.rb', line 2 def id @id end |
#serialized_payload ⇒ Object
Returns the value of attribute 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
#perform ⇒ Object
calls MyJobClass.perform(*payload)
20 21 22 23 |
# File 'lib/eq/job.rb', line 20 def perform const, *payload = unpack const.perform *payload end |
#unpack ⇒ Object
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 |