Class: Rack::Access::Capture::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/access/capture/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Config

Returns a new instance of Config.



37
38
39
40
41
42
43
# File 'lib/rack/access/capture/config.rb', line 37

def initialize(config = {})
  converted_config = convert_hash(config)

  self.collector = converted_config["collector"] if converted_config.key?("collector")
  self.watcher = converted_config["watcher"] if converted_config.key?("watcher")
  self.filter = converted_config["filter"]
end

Instance Attribute Details

#_collectorObject (readonly)

Returns the value of attribute _collector.



10
11
12
# File 'lib/rack/access/capture/config.rb', line 10

def _collector
  @_collector
end

#_internal_watcherObject (readonly)

Returns the value of attribute _internal_watcher.



10
11
12
# File 'lib/rack/access/capture/config.rb', line 10

def _internal_watcher
  @_internal_watcher
end

#_watcherObject (readonly)

Returns the value of attribute _watcher.



10
11
12
# File 'lib/rack/access/capture/config.rb', line 10

def _watcher
  @_watcher
end

Class Method Details

.config_accessor(*names) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rack/access/capture/config.rb', line 13

def config_accessor(*names)
  names.each do |name|
    class_eval <<-METHOD
      def #{name}
        @#{name}
      end

      def #{name}=(value)
        @#{name} = value
        if "#{name}" == "filter"
          @_internal_watcher = Rack::Access::Capture::Watcher::InternalWatcherAdapter.new(convert_hash(value))
        else
          @_#{name} = Object.const_get("Rack::Access::Capture::#{name.capitalize}::Adapters").send("interpret_#{name}", convert_hash(value))
        end
      end
    METHOD
  end
end