Sha256: 0acc3d4ba3da12d932465b948fa57f1e28ebabc030f5b2ee97951afb47a4a7dd

Contents?: true

Size: 1.15 KB

Versions: 23

Compression:

Stored size: 1.15 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
      }

      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

      def min_delay_between_events
        @min_delay_between_events
      end

      def silencer_rules
        @silencer_rules
      end

      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

23 entries across 23 versions & 8 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/listen-3.0.8/lib/listen/listener/config.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/listen-3.0.8/lib/listen/listener/config.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/listen-3.0.8/lib/listen/listener/config.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/listen-3.0.8/lib/listen/listener/config.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/listen-3.0.8/lib/listen/listener/config.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/listen-3.0.8/lib/listen/listener/config.rb
listen-3.0.8 lib/listen/listener/config.rb
sass-listen-3.0.7 lib/listen/listener/config.rb
listen-3.0.7 lib/listen/listener/config.rb
listen-3.0.6 lib/listen/listener/config.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/listen-3.0.5/lib/listen/listener/config.rb
listen-3.0.5 lib/listen/listener/config.rb
listen-3.0.4 lib/listen/listener/config.rb
mastermind_adeybee-0.1.4 vendor/bundle/ruby/2.2.0/gems/listen-3.0.3/lib/listen/listener/config.rb
mastermind_adeybee-0.1.3 vendor/bundle/ruby/2.2.0/gems/listen-3.0.3/lib/listen/listener/config.rb
mastermind_adeybee-0.1.2 vendor/bundle/ruby/2.2.0/gems/listen-3.0.3/lib/listen/listener/config.rb
mastermind_adeybee-0.1.1 vendor/bundle/ruby/2.2.0/gems/listen-3.0.3/lib/listen/listener/config.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/listen-3.0.3/lib/listen/listener/config.rb
geminfo-0.1.0 path/gems/listen-3.0.3/lib/listen/listener/config.rb
listen-3.0.3 lib/listen/listener/config.rb