lib/eco/api/session/batch/jobs.rb in eco-helpers-1.5.1 vs lib/eco/api/session/batch/jobs.rb in eco-helpers-1.5.2
- old
+ new
@@ -23,11 +23,11 @@
def empty?
count == 0
end
- def each(params: {}, &block)
+ def each(&block)
return to_enum(:each) unless block
items.each(&block)
end
def items
@@ -47,16 +47,21 @@
self[name].tap do |job|
block.call(job) if block
end
end
- def new(name, type:, sets:, usecase: nil)
+ def new(name, type:, sets:, usecase: nil, &block)
fatal "Can't create job named '#{name}' because it already exists." if exists?(name)
Batch::Job.new(enviro, name: name, type: type, sets: sets, usecase: usecase).tap do |job|
- @jobs[name] = job
- @callbacks[job] = Proc.new if block_given?
+ add(job, &block)
end
+ end
+
+ def add(job)
+ fatal "Expected Eco::API::Session::Batch::Job object. Given #{job.class}" unless job.is_a?(Eco::API::Session::Batch::Job)
+ @jobs[job.name] = job
+ @callbacks[job] = Proc.new if block_given?
end
def pending?
any? {|job| job.pending?}
end