Module: DaimonSkycrawlers::Callbacks

Included in:
DaimonSkycrawlers::Crawler::Base, Processor::Base
Defined in:
lib/daimon_skycrawlers/callbacks.rb

Instance Method Summary collapse

Instance Method Details

#before_process(callback = nil, &block) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/daimon_skycrawlers/callbacks.rb', line 8

def before_process(callback = nil, &block)
  if block_given?
    @before_process_callbacks << block
  else
    @before_process_callbacks << callback if callback.respond_to?(:call)
  end
end

#clear_before_process_callbacksObject



22
23
24
# File 'lib/daimon_skycrawlers/callbacks.rb', line 22

def clear_before_process_callbacks
  @before_process_callbacks = []
end

#initializeObject



3
4
5
6
# File 'lib/daimon_skycrawlers/callbacks.rb', line 3

def initialize
  super
  @before_process_callbacks = []
end

#run_before_callbacks(message) ⇒ Object



16
17
18
19
20
# File 'lib/daimon_skycrawlers/callbacks.rb', line 16

def run_before_callbacks(message)
  @before_process_callbacks.all? do |callback|
    callback.call(message)
  end
end