Class: DRbQueue::Server::Work

Inherits:
Struct
  • Object
show all
Defined in:
lib/drb_queue/server.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argsObject

Returns the value of attribute args

Returns:

  • (Object)

    the current value of args



17
18
19
# File 'lib/drb_queue/server.rb', line 17

def args
  @args
end

#workerObject

Returns the value of attribute worker

Returns:

  • (Object)

    the current value of worker



17
18
19
# File 'lib/drb_queue/server.rb', line 17

def worker
  @worker
end

Class Method Details

.unserialize(serialized) ⇒ Object



22
23
24
25
26
27
# File 'lib/drb_queue/server.rb', line 22

def self.unserialize(serialized)
  hash = JSON.parse(serialized)
  worker = hash['worker'].split('::').inject(Object) { |o, k| o.const_get(k) }

  new(worker, hash['args'])
end

Instance Method Details

#performObject



18
19
20
# File 'lib/drb_queue/server.rb', line 18

def perform
  worker.perform(*args)
end

#serializeObject



29
30
31
# File 'lib/drb_queue/server.rb', line 29

def serialize
  {'worker' => worker.to_s, 'args' => args}.to_json
end