Class: Ductr::SequelBase::PollingHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/ductr/sequel_base/polling_handler.rb

Overview

The rufus-scheduler handler class.

Instance Method Summary collapse

Constructor Details

#initialize(method, adapter) ⇒ PollingHandler

Creates the handler based on the given scheduler, its method name and the trigger’s adapter instance.

Parameters:

  • method (Method)

    The scheduler’s method

  • adapter (Ductr::Adapter)

    The trigger’s adapter



17
18
19
20
21
# File 'lib/ductr/sequel_base/polling_handler.rb', line 17

def initialize(method, adapter)
  @method = method
  @adapter = adapter
  @last_triggering_key = nil
end

Instance Method Details

#callvoid

This method returns an undefined value.

The callable method used by the trigger, actually calls the scheduler’s method.



28
29
30
31
32
33
34
35
36
37
# File 'lib/ductr/sequel_base/polling_handler.rb', line 28

def call
  @adapter.open do |db|
    @method.call(db) do |triggering_key|
      return false if triggering_key == @last_triggering_key

      @last_triggering_key = triggering_key
      true
    end
  end
end