Class: ShopifyCLI::ThreadPool::Job

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(interval = 0) ⇒ Job

Returns a new instance of Job.



8
9
10
# File 'lib/shopify_cli/thread_pool/job.rb', line 8

def initialize(interval = 0)
  @interval = interval
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



6
7
8
# File 'lib/shopify_cli/thread_pool/job.rb', line 6

def error
  @error
end

#intervalObject (readonly)

Returns the value of attribute interval.



6
7
8
# File 'lib/shopify_cli/thread_pool/job.rb', line 6

def interval
  @interval
end

Instance Method Details

#callObject



16
17
18
19
20
# File 'lib/shopify_cli/thread_pool/job.rb', line 16

def call
  perform!
rescue StandardError => error
  @error = error
end

#error?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/shopify_cli/thread_pool/job.rb', line 26

def error?
  !!@error
end

#perform!Object



12
13
14
# File 'lib/shopify_cli/thread_pool/job.rb', line 12

def perform!
  raise "`#{self.class.name}#perform!' must be defined"
end

#recurring?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/shopify_cli/thread_pool/job.rb', line 30

def recurring?
  !interval.zero?
end

#success?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/shopify_cli/thread_pool/job.rb', line 22

def success?
  !@error
end