Class: Radar::Config

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

Overview

The configuration class used for applications. To configure your application see Application#config. This is also where all the examples are.

Defined Under Namespace

Classes: UseArray

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/radar/config.rb', line 11

def initialize
  @reporters = UseArray.new do |klass, &block|
    instance = klass.new
    block.call(instance) if block
    [klass, instance]
  end

  @data_extensions = UseArray.new
  @data_extensions.use DataExtensions::HostEnvironment

  @matchers = UseArray.new do |matcher, *args|
    matcher = Support::Inflector.constantize("Radar::Matchers::" + Support::Inflector.camelize(matcher)) if !matcher.is_a?(Class)
    [matcher, matcher.new(*args)]
  end
end

Instance Attribute Details

#data_extensionsObject (readonly)

Returns the value of attribute data_extensions.



8
9
10
# File 'lib/radar/config.rb', line 8

def data_extensions
  @data_extensions
end

#matchersObject (readonly)

Returns the value of attribute matchers.



9
10
11
# File 'lib/radar/config.rb', line 9

def matchers
  @matchers
end

#reportersObject (readonly)

Returns the value of attribute reporters.



7
8
9
# File 'lib/radar/config.rb', line 7

def reporters
  @reporters
end

Instance Method Details

#match(matcher, *args) ⇒ Object

Adds a matcher rule to the application. An application will only report an exception if the event agrees with at least one of the matchers.

To use a matcher, there are two options. The first is to use a symbol for the name:

config.match :class, StandardError

This will cause Radar to search for a class named "ClassMatcher" under the namespace Matchers.

A second option is to use a class itself:

config.match Radar::Matchers::ClassMatcher, StandardError

Radar will then use the specified class as the matcher.



45
46
47
# File 'lib/radar/config.rb', line 45

def match(matcher, *args)
  @matchers.use(matcher, *args)
end