Module: Bellbro::Hooks

Included in:
Worker
Defined in:
lib/bellbro/hooks.rb

Overview

Internal: Methods relating to supporting hooks around Sidekiq worker invocation.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bellbro/hooks.rb', line 4

def self.included(base)
  base.class_eval do
    extend ClassMethods
  end

  def aborted?
    !!@abort
  end

  def abort!
    @abort = true
  end

  def timer
    @timer ||= Bellbro::Timer.new(self.class.time_out_interval)
  end

  def timed_out?
    timer.timed_out?
  end
end

Instance Method Details

#abort!Object



13
14
15
# File 'lib/bellbro/hooks.rb', line 13

def abort!
  @abort = true
end

#aborted?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/bellbro/hooks.rb', line 9

def aborted?
  !!@abort
end

#timed_out?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/bellbro/hooks.rb', line 21

def timed_out?
  timer.timed_out?
end

#timerObject



17
18
19
# File 'lib/bellbro/hooks.rb', line 17

def timer
  @timer ||= Bellbro::Timer.new(self.class.time_out_interval)
end