Class: Radar::Config
- Inherits:
-
Object
- Object
- Radar::Config
- 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
-
#data_extensions ⇒ Object
readonly
Returns the value of attribute data_extensions.
-
#matchers ⇒ Object
readonly
Returns the value of attribute matchers.
-
#reporters ⇒ Object
readonly
Returns the value of attribute reporters.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#match(matcher, *args) ⇒ Object
Adds a matcher rule to the application.
Constructor Details
#initialize ⇒ Config
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_extensions ⇒ Object (readonly)
Returns the value of attribute data_extensions.
8 9 10 |
# File 'lib/radar/config.rb', line 8 def data_extensions @data_extensions end |
#matchers ⇒ Object (readonly)
Returns the value of attribute matchers.
9 10 11 |
# File 'lib/radar/config.rb', line 9 def matchers @matchers end |
#reporters ⇒ Object (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 |