Class: Parapool::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/parapool/job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(param, sync, &block) ⇒ Job

Returns a new instance of Job.

Raises:



7
8
9
10
11
12
13
# File 'lib/parapool/job.rb', line 7

def initialize(param, sync, &block)
  raise Parapool::Error, 'must be called with a block' unless block_given?

  @param = param
  @sync = sync
  @block = block
end

Instance Attribute Details

#paramObject

Returns the value of attribute param.



5
6
7
# File 'lib/parapool/job.rb', line 5

def param
  @param
end

#resultObject

Returns the value of attribute result.



5
6
7
# File 'lib/parapool/job.rb', line 5

def result
  @result
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
# File 'lib/parapool/job.rb', line 15

def run
  @result = @block.call(param) rescue $!

  @sync.count

  @result
end