Sha256: 331cced42ea402d11dfdc8a7cb3e7e85742fa55314bf0041b2fa0136237b1361

Contents?: true

Size: 830 Bytes

Versions: 2

Compression:

Stored size: 830 Bytes

Contents

# frozen_string_literal: true

module Ductr
  module Sequel
    #
    # A trigger based on the RufusTrigger, runs the PollingHandler at the given timing.
    #
    class PollingTrigger < Ductr::RufusTrigger
      #
      # Closes the connection if the scheduler is stopped.
      #
      # @return [void]
      #
      def stop
        super
        adapter.close!
      end

      private

      #
      # Returns a callable object, allowing rufus-scheduler to call it.
      #
      # @param [Ductr::Scheduler] scheduler The scheduler instance
      # @param [Method] method The scheduler's method
      # @param [Hash] ** The option passed to the trigger annotation
      #
      # @return [#call] A callable object
      #
      def callable(method, **)
        PollingHandler.new(method, adapter)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ductr-0.2.1 lib/ductr/sequel/polling_trigger.rb
ductr-0.2.0 lib/ductr/sequel/polling_trigger.rb