Sha256: 9f83bfdc5c49dc6a831b2ae2c207176e8a1a1af601910e123d3908fefe8a3176

Contents?: true

Size: 834 Bytes

Versions: 2

Compression:

Stored size: 834 Bytes

Contents

# frozen_string_literal: true

module Ductr
  module SequelBase
    #
    # 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.3 lib/ductr/sequel_base/polling_trigger.rb
ductr-0.2.2 lib/ductr/sequel_base/polling_trigger.rb