Class: Driskell::Listen::Listener::Config
- Inherits:
-
Object
- Object
- Driskell::Listen::Listener::Config
- 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
- #adapter_instance_options(klass) ⇒ Object
- #adapter_select_options ⇒ Object
-
#initialize(opts) ⇒ Config
constructor
A new instance of Config.
- #min_delay_between_events ⇒ Object
- #relative? ⇒ Boolean
- #silencer_rules ⇒ Object
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 (klass) valid_keys = klass.const_get('DEFAULTS').keys Hash[@options.select { |key, _| valid_keys.include?(key) }] end |
#adapter_select_options ⇒ Object
39 40 41 42 |
# File 'lib/driskell-listen/listener/config.rb', line 39 def valid_keys = %w(force_polling polling_fallback_message).map(&:to_sym) Hash[@options.select { |key, _| valid_keys.include?(key) }] end |
#min_delay_between_events ⇒ Object
26 27 28 |
# File 'lib/driskell-listen/listener/config.rb', line 26 def min_delay_between_events @min_delay_between_events end |
#relative? ⇒ Boolean
22 23 24 |
# File 'lib/driskell-listen/listener/config.rb', line 22 def relative? @relative end |
#silencer_rules ⇒ Object
30 31 32 |
# File 'lib/driskell-listen/listener/config.rb', line 30 def silencer_rules @silencer_rules end |