|
@@ -24,12 +24,12 @@ module JobsHelper
|
|
|
#
|
|
|
# Can return nil, or an instance of Agent.
|
|
|
def agent_from_job(job)
|
|
|
- begin
|
|
|
- Agent.find_by_id(YAML.load(job.handler).job_data['arguments'][0])
|
|
|
- rescue ArgumentError
|
|
|
- # We can get to this point before all of the agents have loaded (usually,
|
|
|
- # in development)
|
|
|
- nil
|
|
|
+ if data = YAML.load(job.handler).try(:job_data)
|
|
|
+ Agent.find_by_id(data['arguments'][0])
|
|
|
end
|
|
|
+ rescue ArgumentError
|
|
|
+ # We can get to this point before all of the agents have loaded (usually,
|
|
|
+ # in development)
|
|
|
+ nil
|
|
|
end
|
|
|
end
|