Class: Driskell::Listen::Silencer::Controller

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

Instance Method Summary collapse

Constructor Details

#initialize(silencer, default_options) ⇒ Controller

Returns a new instance of Controller.



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/driskell-listen/silencer/controller.rb', line 4

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



17
18
19
20
# File 'lib/driskell-listen/silencer/controller.rb', line 17

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

#replace_with_bang_ignores(regexps) ⇒ Object



22
23
24
# File 'lib/driskell-listen/silencer/controller.rb', line 22

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

#replace_with_only(regexps) ⇒ Object



26
27
28
# File 'lib/driskell-listen/silencer/controller.rb', line 26

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