Class: Listen::Silencer::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/listen/silencer/controller.rb

Instance Method Summary collapse

Constructor Details

#initialize(silencer, default_options) ⇒ Controller

Returns a new instance of Controller.


6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/listen/silencer/controller.rb', line 6

def initialize(silencer, default_options)
  @silencer = silencer

  opts = default_options

  @prev_silencer_options = {}
  rules = [:only, :ignore, :ignore!].map do |option|
    [option, opts[option]] if opts.key? option
  end

  _reconfigure_silencer(Hash[rules.compact])
end

Instance Method Details

#append_ignores(*regexps) ⇒ Object


19
20
21
22
# File 'lib/listen/silencer/controller.rb', line 19

def append_ignores(*regexps)
  prev_ignores = Array(@prev_silencer_options[:ignore])
  _reconfigure_silencer(ignore: [prev_ignores + regexps])
end

#replace_with_bang_ignores(regexps) ⇒ Object


24
25
26
# File 'lib/listen/silencer/controller.rb', line 24

def replace_with_bang_ignores(regexps)
  _reconfigure_silencer(ignore!: regexps)
end

#replace_with_only(regexps) ⇒ Object


28
29
30
# File 'lib/listen/silencer/controller.rb', line 28

def replace_with_only(regexps)
  _reconfigure_silencer(only: regexps)
end