Class: Driskell::Listen::Listener::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/driskell-listen/listener/config.rb

Constant Summary collapse

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
}

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Config

Returns a new instance of Config.



15
16
17
18
19
20
# File 'lib/driskell-listen/listener/config.rb', line 15

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

Instance Method Details

#adapter_instance_options(klass) ⇒ Object



34
35
36
37
# File 'lib/driskell-listen/listener/config.rb', line 34

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

#adapter_select_optionsObject



39
40
41
42
# File 'lib/driskell-listen/listener/config.rb', line 39

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

#min_delay_between_eventsObject



26
27
28
# File 'lib/driskell-listen/listener/config.rb', line 26

def min_delay_between_events
  @min_delay_between_events
end

#relative?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/driskell-listen/listener/config.rb', line 22

def relative?
  @relative
end

#silencer_rulesObject



30
31
32
# File 'lib/driskell-listen/listener/config.rb', line 30

def silencer_rules
  @silencer_rules
end