Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ensure a valid configuration object is always available on Airbrake.c…

…onfiguration
  • Loading branch information...
commit 5dbf4d272db881864a5f2f75b87068363b1d1b41 1 parent 3e289ce
Harold Giménez authored
Showing with 12 additions and 2 deletions.
  1. +7 −2 lib/airbrake.rb
  2. +5 −0 test/configuration_test.rb
View
9 lib/airbrake.rb
@@ -35,7 +35,7 @@ class << self
# A Airbrake configuration object. Must act like a hash and return sensible
# values for all Airbrake configuration options. See Airbrake::Configuration.
- attr_accessor :configuration
+ attr_writer :configuration
# Tell the log that the Notifier is good to go
def report_ready
@@ -77,12 +77,17 @@ def logger
# config.secure = false
# end
def configure(silent = false)
- self.configuration ||= Configuration.new
yield(configuration)
self.sender = Sender.new(configuration)
report_ready unless silent
end
+ # The configuration object.
+ # @see Airbrake.configure
+ def configuration
+ @configuration ||= Configuration.new
+ end
+
# Sends an exception manually using this method, even when you are not in a controller.
#
# @param [Exception] exception The exception you want to notify Airbrake about.
View
5 test/configuration_test.rb
@@ -181,6 +181,11 @@ class ConfigurationTest < Test::Unit::TestCase
assert_equal "CUSTOM LOGGER", config.logger
end
+ should 'give a new instance if non defined' do
+ Airbrake.configuration = nil
+ assert_kind_of Airbrake::Configuration, Airbrake.configuration
+ end
+
def assert_config_default(option, default_value, config = nil)
config ||= Airbrake::Configuration.new
assert_equal default_value, config.send(option)
Please sign in to comment.
Something went wrong with that request. Please try again.