Sha256: 0e8d980598c1d80122bca05b67fb2cd6ffc9cc6ae1d8250f1e9ef1264a44f54b

Contents?: true

Size: 1.1 KB

Versions: 55

Compression:

Stored size: 1.1 KB

Contents

module Listen
  class Listener
    class Config
      DEFAULTS = {
        # Listener options
        debug: false, # TODO: is this broken?
        wait_for_delay: nil, # NOTE: should be provided by adapter if possible
        relative: false,

        # Backend selecting options
        force_polling: false,
        polling_fallback_message: nil
      }.freeze

      def initialize(opts)
        @options = DEFAULTS.merge(opts)
        @relative = @options[:relative]
        @min_delay_between_events = @options[:wait_for_delay]
        @silencer_rules = @options # silencer will extract what it needs
      end

      def relative?
        @relative
      end

      attr_reader :min_delay_between_events

      attr_reader :silencer_rules

      def adapter_instance_options(klass)
        valid_keys = klass.const_get('DEFAULTS').keys
        Hash[@options.select { |key, _| valid_keys.include?(key) }]
      end

      def adapter_select_options
        valid_keys = %w(force_polling polling_fallback_message).map(&:to_sym)
        Hash[@options.select { |key, _| valid_keys.include?(key) }]
      end
    end
  end
end

Version data entries

55 entries across 48 versions & 9 rubygems

Version Path
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/listen-3.2.1/lib/listen/listener/config.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/listen-3.1.5/lib/listen/listener/config.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/listen-3.1.5/lib/listen/listener/config.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/listen-3.1.5/lib/listen/listener/config.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/listen-3.1.5/lib/listen/listener/config.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/listen-3.1.5/lib/listen/listener/config.rb
listen-3.2.1 lib/listen/listener/config.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/listen-3.1.5/lib/listen/listener/config.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/listen-3.1.5/lib/listen/listener/config.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/listen-3.1.5/lib/listen/listener/config.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/listen-3.1.5/lib/listen/listener/config.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/listen-3.1.5/lib/listen/listener/config.rb
listen-3.2.0 lib/listen/listener/config.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/listen-3.1.5/lib/listen/listener/config.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/listen-3.1.5/lib/listen/listener/config.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/listen-3.1.5/lib/listen/listener/config.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/listen-3.1.5/lib/listen/listener/config.rb
alimentos-alu0100945645-0.1.0 vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/listener/config.rb
alimentos-alu0100945645-1.0.0 vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/listener/config.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/listen-3.1.5/lib/listen/listener/config.rb