Class: Listen::Listener::Config
- Inherits:
-
Object
- Object
- Listen::Listener::Config
- Defined in:
- lib/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 }.freeze
Instance Attribute Summary collapse
-
#min_delay_between_events ⇒ Object
readonly
Returns the value of attribute min_delay_between_events.
-
#silencer_rules ⇒ Object
readonly
Returns the value of attribute silencer_rules.
Instance Method Summary collapse
- #adapter_instance_options(klass) ⇒ Object
- #adapter_select_options ⇒ Object
-
#initialize(opts) ⇒ Config
constructor
A new instance of Config.
- #relative? ⇒ Boolean
Constructor Details
#initialize(opts) ⇒ Config
Returns a new instance of Config.
17 18 19 20 21 22 |
# File 'lib/listen/listener/config.rb', line 17 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 Attribute Details
#min_delay_between_events ⇒ Object (readonly)
Returns the value of attribute min_delay_between_events.
28 29 30 |
# File 'lib/listen/listener/config.rb', line 28 def min_delay_between_events @min_delay_between_events end |
#silencer_rules ⇒ Object (readonly)
Returns the value of attribute silencer_rules.
28 29 30 |
# File 'lib/listen/listener/config.rb', line 28 def silencer_rules @silencer_rules end |
Instance Method Details
#adapter_instance_options(klass) ⇒ Object
30 31 32 33 |
# File 'lib/listen/listener/config.rb', line 30 def (klass) valid_keys = klass.const_get('DEFAULTS').keys Hash[@options.select { |key, _| valid_keys.include?(key) }] end |
#adapter_select_options ⇒ Object
35 36 37 38 |
# File 'lib/listen/listener/config.rb', line 35 def valid_keys = %w[force_polling polling_fallback_message].map(&:to_sym) Hash[@options.select { |key, _| valid_keys.include?(key) }] end |
#relative? ⇒ Boolean
24 25 26 |
# File 'lib/listen/listener/config.rb', line 24 def relative? @relative end |