Class: Instrumental::Configuration
- Inherits:
-
Object
- Object
- Instrumental::Configuration
- Defined in:
- lib/instrumental/configuration.rb
Constant Summary collapse
- DEFAULT_REPORT_INTERVAL =
15.0
Instance Attribute Summary collapse
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#host ⇒ Object
Returns the value of attribute host.
- #logger ⇒ Object
-
#name_prefix ⇒ Object
Returns the value of attribute name_prefix.
-
#path ⇒ Object
Returns the value of attribute path.
-
#port ⇒ Object
Returns the value of attribute port.
-
#report_interval ⇒ Object
Returns the value of attribute report_interval.
Instance Method Summary collapse
- #api_key ⇒ Object
- #api_key=(val) ⇒ Object
- #enabled? ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
16 17 18 19 20 21 22 23 |
# File 'lib/instrumental/configuration.rb', line 16 def initialize @enabled = defined?(::Rails.env) ? Rails.env.production? : true @host = 'in.imperialapp.com' @port = 80 @name_prefix = '' @path = '/in/' @report_interval = DEFAULT_REPORT_INTERVAL end |
Instance Attribute Details
#enabled ⇒ Object
Returns the value of attribute enabled.
12 13 14 |
# File 'lib/instrumental/configuration.rb', line 12 def enabled @enabled end |
#host ⇒ Object
Returns the value of attribute host.
8 9 10 |
# File 'lib/instrumental/configuration.rb', line 8 def host @host end |
#logger ⇒ Object
63 64 65 66 67 |
# File 'lib/instrumental/configuration.rb', line 63 def logger # The Rails logger is not available in an initializer, so we have to look for on-demand. @logger ||= defined?(::Rails.logger) ? Rails.logger : Logger.new(STDOUT) @logger end |
#name_prefix ⇒ Object
Returns the value of attribute name_prefix.
14 15 16 |
# File 'lib/instrumental/configuration.rb', line 14 def name_prefix @name_prefix end |
#path ⇒ Object
Returns the value of attribute path.
10 11 12 |
# File 'lib/instrumental/configuration.rb', line 10 def path @path end |
#port ⇒ Object
Returns the value of attribute port.
9 10 11 |
# File 'lib/instrumental/configuration.rb', line 9 def port @port end |
#report_interval ⇒ Object
Returns the value of attribute report_interval.
11 12 13 |
# File 'lib/instrumental/configuration.rb', line 11 def report_interval @report_interval end |
Instance Method Details
#api_key ⇒ Object
59 60 61 |
# File 'lib/instrumental/configuration.rb', line 59 def api_key @api_key || raise(ArgumentError, 'API key must be set in configuration') end |
#api_key=(val) ⇒ Object
53 54 55 56 57 |
# File 'lib/instrumental/configuration.rb', line 53 def api_key=(val) @api_key = val raise(ArgumentError, 'API key is invalid') unless @api_key =~ /^[a-f\d]{32}$/ end |
#enabled? ⇒ Boolean
25 26 27 |
# File 'lib/instrumental/configuration.rb', line 25 def enabled? !!@enabled end |