Class: Muffler::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/muffler/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



5
6
7
8
9
10
11
12
13
14
# File 'lib/muffler/config.rb', line 5

def initialize
  @header = 'HTTP_X_MUFFLE_LOGGER' # send in header as X-Muffle-Logger
  @ips = []
  @paths = []
  @mufflers = {}

  muffle_with(:header) { |opts| !opts[@header].nil? }
  muffle_with(:ip)     { |opts| @ips.any? { |ip| ip === opts['REMOTE_ADDR'] } }
  muffle_with(:path)   { |opts| @paths.any? { |path| path === opts['PATH_INFO'] } }
end

Instance Attribute Details

#headerObject

Returns the value of attribute header.



3
4
5
# File 'lib/muffler/config.rb', line 3

def header
  @header
end

#ipsObject

Returns the value of attribute ips.



3
4
5
# File 'lib/muffler/config.rb', line 3

def ips
  @ips
end

#mufflersObject

Returns the value of attribute mufflers.



3
4
5
# File 'lib/muffler/config.rb', line 3

def mufflers
  @mufflers
end

#pathsObject

Returns the value of attribute paths.



3
4
5
# File 'lib/muffler/config.rb', line 3

def paths
  @paths
end

Instance Method Details

#muffle_with(name, &block) ⇒ Object



16
17
18
# File 'lib/muffler/config.rb', line 16

def muffle_with(name, &block)
  @mufflers[name] = block
end