Class: Job

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
lib/swarm/job.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.activeObject

Return array of active jobs.



64
65
66
# File 'lib/swarm/job.rb', line 64

def self.active
  all :active => true
end

.for(agent) ⇒ Object

Return active job for agent.



55
56
57
58
59
# File 'lib/swarm/job.rb', line 55

def self.for agent
  active.find do |job|
    not agent.jobs.include?(job) || job.agents.any? { |other| agent.string == other.string }
  end
end

Instance Method Details

#active?Boolean

Check if the job is active.

Returns:

  • (Boolean)


33
34
35
# File 'lib/swarm/job.rb', line 33

def active?
  active
end

#to_jsonObject

Job JSON.



40
41
42
43
44
45
46
# File 'lib/swarm/job.rb', line 40

def to_json
  { :id => id, 
    :source => source,
    :results => results,
    :address => address,
    :active => active }.to_json
end